Skip to content

API Reference

HTMX.HTMX Module
julia
HTMX

Lightweight HTML builder wrapping Cobweb.jl.

Exports

  • h — tag-based HTML node builder (h.div(...), h.p("text"))

  • Node — immutable wrapper around Cobweb.Node

  • auto — convert arbitrary values to HTML response strings

  • @__str — string literal macro for HyperscriptString

source
HTMX.HyperscriptString Type
julia
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.

source
HTMX.Node Type
julia
Node(tag, children...; attributes...)

Immutable wrapper around Cobweb.Node. Keyword arguments become HTML attributes (underscores are converted to hyphens, e.g. hx_gethx-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:

julia
node = h.div(class="container")
node("child text")   # returns a new Node; original is unchanged

During HTML rendering, HyperscriptString children are moved to the _ attribute (for hyperscript).

source
HTMX.auto Method
julia
auto(x; wrap=identity)

Convert x to an HTML string, applying wrap to the result.

  • AbstractString — passed through to wrap

  • AbstractArray — elements are recursively auto'd and joined with newlines

  • Pair(content, id) — wrapped in an OOB-swap div with hx-swap-oob="true"

  • Anything else — rendered via repr("text/html", x)

source
HTMX.h Method
julia
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:

julia
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").

source
HTMX.md_to_node Method
julia
md_to_node(md)

Convert a markdown string or Markdown.jl AST into h.* HTML nodes.

Example

julia
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")))
source
HTMX.@__str Macro
julia
@__str "text"

Create a HyperscriptString literal. Equivalent to HyperscriptString("text").

source
You are viewing the dev branch. This branch may include code written with Claude Code with less human supervision. Only human-approved code is merged into main.