A whole HTML page as a string

Description

For servers that answer with HTML text rather than tags, like plumber2, ambiorix or nanonext. Writes the doctype, the head and the body, with the stylesheet and every script the components asked for already linked.

Usage

bc_page(
  ...,
  title = NULL,
  assets = "/basecoat/",
  style = NULL,
  theme = NULL,
  head = NULL,
  lang = "en"
)

Arguments

Argument Description
... Children of the <body>.
title String. The page title.
assets String. The URL the bundled Basecoat directory is served from.
style String or NULL. A style pack, as in bc_deps().
theme String or NULL. Path to a CSS file of your own. It lands in the head after the style pack, so its tokens win.
head Tag or NULL. Anything else the head needs, such as the script tag for htmx.
lang String. The lang attribute on <html>.

Value

A single string.

Details

Serve system.file("basecoat", package = "basecoat") at assets. The files ship inside the package, where a browser cannot reach them, so every dependency is rewritten to that prefix.

theme is read and written into a <style> tag, so the file itself does not have to be served.

See Also

bc_deps(), bc_page_sidebar(), bc_page_navbar()

Examples

cat(substr(bc_page(bc_button("Save"), title = "Demo"), 1, 80))
#> <!doctype html>
#> <html lang="en">
#> <head>
#> <meta charset="utf-8">
#> <title>Demo</titl

theme <- system.file("examples", "tweakcn-theme.css", package = "basecoat")
page <- bc_page(bc_button("Save"), theme = theme)