You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
The first element of the vector is used as the element name. The secondattribute can optionally be a map, in which case it is used to supplythe element's attributes. Every other element is considered part of thetag's body.
Hiccup is intelligent enough to render different HTML elements indifferent ways, in order to accommodate browser quirks:
If the body of the element is a seq, its contents will be expanded outinto the element body. This makes working with forms likemap andfor more convenient:
In brief: Hiccup 1 doesn't escape strings by default, while Hiccup 2does. They occupy different namespaces to ensure backward compatibility.
In Hiccup 1, you use theh function to escape a string - that is,ensure that unsafe characters like<,> and& are converted intotheir equivalent entity codes:
(h1/html [:div"Username:" (h1/h username)])
In Hiccup 2 strings are escaped automatically, but the return value fromthehtml macro is aRawString, rather than aString. This ensuresthat thehtml macro can still be nested.
(str (h2/html [:div"Username:" username]))
It's recommended to use Hiccup 2 where possible, particularly if yourapp handles user data. Use of the non-core namespaces, such ashiccup.page, should be avoided with Hiccup 2.