API Reference
HTMX.HTMX Module
HTMXLightweight HTML builder wrapping Cobweb.jl.
Exports
h— tag-based HTML node builder (h.div(...),h.p("text"))Node— immutable wrapper aroundCobweb.Nodeauto— convert arbitrary values to HTML response strings@__str— string literal macro forHyperscriptString
HTMX.HyperscriptString Type
HyperscriptString(s::AbstractString)A string subtype that, when passed as a child to a Node, is moved to the _ (hyperscript) HTML attribute instead of appearing as text content.
Multiple HyperscriptString children are concatenated with newlines in the _ attribute. Concatenation via * preserves the HyperscriptString type.
See also @__str for a literal constructor.
HTMX.Node Type
Node(tag, children...; attributes...)Immutable wrapper around Cobweb.Node. Keyword arguments become HTML attributes (underscores are converted to hyphens, e.g. hx_get → hx-get). Attributes set to nothing or false are omitted; true renders as a bare attribute. Positional arguments become children.
Use call syntax to append children or merge attributes:
node = h.div(class="container")
node("child text") # returns a new Node; original is unchangedDuring HTML rendering, HyperscriptString children are moved to the _ attribute (for hyperscript).
HTMX.auto Method
auto(x; wrap=identity)Convert x to an HTML string, applying wrap to the result.
AbstractString— passed through towrapAbstractArray— elements are recursivelyauto'd and joined with newlinesPair(content, id)— wrapped in an OOB-swapdivwithhx-swap-oob="true"Anything else — rendered via
repr("text/html", x)
HTMX.h Method
h(tag, children...; attributes...)
h.tag(children...; attributes...)Create an HTML Node. The property-access form h.div(...) is the standard way to build elements:
h.div(class="container")(
h.h1("Title"),
h.p("Paragraph")
)Keyword arguments become attributes (underscores → hyphens). Positional arguments become children. Attributes set to nothing or false are omitted; true renders as a bare attribute (e.g. checked not checked="true").
HTMX.md_to_node Method
md_to_node(md)Convert a markdown string or Markdown.jl AST into h.* HTML nodes.
Example
md_to_node("**bold** and `code`")
md_to_node(Markdown.parse("**bold** and `code`"))
# both => h.div(h.p(h.strong("bold"), " and ", h.code("code")))HTMX.@__str Macro
@__str "text"Create a HyperscriptString literal. Equivalent to HyperscriptString("text").