Skip to content

MichaelHatherly/HypertextTemplates.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HypertextTemplates.jl

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.

Features

  • 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

Quick Example

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

Installation

pkg> add HypertextTemplates

julia> using HypertextTemplates

Documentation

For comprehensive documentation, examples, and guides, visit the documentation.

License

This package is licensed under the MIT License.

About

Hypertext templating DSL for Julia

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •