============================ Core Functions - Render HTML ============================ The core module contains the :hy:func:`html` function which renders HTML from data structure. All strings are escaped by default; to prevent a string to be escaped, use the :hy:func:`raw` function. Syntax Reminder =============== .. tab:: Hy .. code:: clj => (html ["p"]) "

" => (html ["p" "some text"]) "

some text

" => (html ["p" {"attr" "an-attr"} "some text"]) "

some text

" => (html ["p" (dict :attr "an-attr") ["div" "lorem"] ["div" "ipsum"]]) "

lorem
ipsum

" => (html ["p" {"attr" "an-attr"} *[["div" "lorem"] ["div" "ipsum"]]]) "

lorem
ipsum

" => (html ["p" {"attr" "an-attr"} (iter [["div" "lorem"] ["div" "ipsum"]])]) "

lorem
ipsum

" .. tab:: Python .. code-block:: >>> html(['p']) '

' >>> html(['p', 'some text']) '

some text

' >>> html(['p', {'attr': 'an-attr'}, 'some text']) '

some text

' >>> html(['p', {'attr': 'an-attr'}, ['div', 'lorem'], ['div', 'ipsum']]) '

lorem
ipsum

' >>> html(['p', {'attr': 'an-attr'}, *[['div', 'lorem'], ['div', 'ipsum']]]) '

lorem
ipsum

' >>> html(['p', {'attr': 'an-attr'}, iter([['div', 'lorem'], ['div', 'ipsum']])]) '

lorem
ipsum

' String Escaping =============== By default, :hy:func:`html` escapes all strings. This behaviour can be customized with `escape-strings` parameter: .. tab:: Hy .. code-block:: clj => (setv content ["p" "line
other"]) => (html content :escape-strings False) "

line
other

" .. tab:: Python .. code-block:: >>> content = ['p', 'line
other'] >>> html(content, escape_strings=False) '

line
other

' :hy:func:`raw` function can be used to prevent a single expression to be escaped: .. tab:: Hy .. code-block:: clj => (setv content ["p" (raw "line
other")]) => (html content) "

line
other

" .. tab:: Python .. code-block:: >>> content = ['p', raw('line
other')] >>> html(content) '

line
other

' Note that :hy:func:`html` returns a raw string: .. tab:: Hy .. code-block:: clj => (setv content (html ["p" "some text"])) => (html ["div" content]) "

some text

" .. tab:: Python .. code-block:: >>> content = html(['p', 'some text']) >>> html(['div', content]) '

some text

' API === **Source code:** `hyccup/core.hy `_ .. hy:automodule:: hyccup.core :members: html, raw