Page - Create Documents#

This module contains functions for rendering HTML documents.

Basic Example#

(import hyccup.page [html5 include-css include-js])

(html5 ["p" "hello world"])
;; "<!DOCTYPE html>\n<html><p>hello world</p></html>"

(html5
  ["head"
    #* (include-css "/my.css")
    #* (include-js "/my.js")]
  ["body" "hello world"])
;; "<!DOCTYPE html>
;; <html>
;; <head>
;;   <link href=\"/my.css\" rel=\"stylesheet\" type=\"text/css\">
;;   <script src=\"/my.js\" type=\"text/javascript\"></script>
;; </head>
;; <body>hello world</body>
;; </html>"
from hyccup.page import html5, include_js, include_css

html5(['p', 'hello world'])
# '<!DOCTYPE html>\n<html><p>hello world</p></html>'

html5(['head',
       *include-css('/my.css'),
       *include-js('/my.js')],
      ['body', 'hello world'])
# '<!DOCTYPE html>
# <html>
# <head>
#   <link href="/my.css" rel="stylesheet" type="text/css">
#   <script src="/my.js" type="text/javascript"></script>
# </head>
# <body>hello world</body>
# </html>'

API#

Source code: hyccup/page.hy