HTML templating system for Julia
HypertextTemplates.jl provides a Julian approach to writing HTML using macros that feel natural within the language. Build web pages using Julia's control flow, components, and type safety—all with zero-allocation rendering for maximum performance.
- Native Julia syntax - Write HTML using macros that integrate seamlessly with Julia's control flow
- Component system - Create reusable components with props and slots
- Context system - Pass data through component trees without prop drilling using
@context
and@get_context
- Zero-allocation rendering - Direct IO streaming without intermediate DOM construction
- Automatic HTML escaping - Secure by default with automatic escaping, use
SafeString
for trusted content - Development tools - Source location tracking and editor integration for debugging
- Streaming rendering - Asynchronous rendering with micro-batched output
- Markdown integration - Create components from Markdown files with interpolation support
using HypertextTemplates
using HypertextTemplates.Elements
# Define a reusable component
@component function article_card(; title, author, content)
@article {class = "card"} begin
@header begin
@h1 $title
@p {class = "author"} "by " $author
end
@div {class = "content"} $content
end
end
@deftag macro article_card end
# Render HTML
html = @render @div {class = "container"} begin
@article_card {
title = "Hello, HypertextTemplates!",
author = "Julia Developer",
content = "Building web content with Julia is fast and elegant."
}
end
pkg> add HypertextTemplates
julia> using HypertextTemplates
For comprehensive documentation, examples, and guides, visit the documentation.
This package is licensed under the MIT License.