HypertextTemplates.jl
HTML templating system for Julia
HypertextTemplates.jl is a powerful and efficient HTML templating system that lets you write HTML using Julia's macro syntax. It provides zero-allocation rendering, a sophisticated component system, and seamless integration with Julia's ecosystem.
Key Features
- Natural Syntax - Write HTML using Julia macros that feel like native code
- Zero-allocation rendering - Direct IO streaming without intermediate DOM construction
- Component System - Build reusable components with props and slots
- Context System - Pass data through component trees without prop drilling
- Automatic HTML escaping - Automatic XSS protection with context-aware escaping
- Development tools - Source location tracking and editor integration
- Streaming rendering - Asynchronous rendering with micro-batched output
- Markdown Support - Create components from Markdown files
Quick Start
using HypertextTemplates
using HypertextTemplates.Elements
# Simple example
html = @render @div {class = "container"} begin
@h1 "Welcome to HypertextTemplates!"
@p "Build fast, secure web applications with Julia."
end
<div class="container">
<h1>Welcome to HypertextTemplates!</h1>
<p>Build fast, secure web applications with Julia.</p>
</div>
# Component example
@component function article_card(; title, author, content)
@article {class = "card"} begin
@header begin
@h2 {class = "card-title"} $title
@p {class = "author"} "by " $author
end
@div {class = "card-body"} $content
end
end
@deftag macro article_card end
# Use the component
@render @article_card {
title = "Hello",
author = "Julia Developer",
content = "This is a reusable component!"
}
<article class="card">
<header>
<h2 class="card-title">Hello</h2>
<p class="author">by Julia Developer</p>
</header>
<div class="card-body">This is a reusable component!</div>
</article>
Documentation
Getting Started
- Getting Started Guide - Installation and first steps
- Core Concepts - Understanding the fundamentals
Building Applications
- Components Guide - Creating reusable UI components
- Elements & Attributes - Working with HTML elements
- Rendering & Performance - Optimization and streaming
Advanced Topics
- Advanced Features - Once rendering, dynamic components
- Markdown Integration - Using Markdown with templates
API Reference
- Public API - Core functions, macros, and types
- Library Components - Pre-built UI component library
- Internal API - Implementation details and internals