1 unstable release

Uses old Rust 2015

0.1.0 Apr 14, 2016

#439 in Template engine

27 downloads per month
Used in borealis_codegen




Build Status

Borealis is a templating engine for HTML5 written in Rust.


// Enable compiler plugins. Note that this only works in nightly.

// Let the plugin derive `SerializeDocument` for us.
struct Template {
    value: String,

The template file needs to be in the same directory as the code file.

<!DOCTYPE html>
        {{ self.value }}

You can now call borealis::serializer::serialize on a Template to serialize it to a writer.

use borealis::serializer;

// Create a buffer which we can write too.
// Normally this would be a TCP stream or similar.
let mut writer: Vec<u8> = Vec::new();

// Create a new template.
let template = Template {
    value: "test".into(),

// Turn it into a document and serialize it into our buffer.
serializer::serialize(&mut writer, template);



#[template_fragment(file="template.html", trim)]
struct Template {
    value: u32,

The trim flag means that the plugin will trim any whitespace before parsing the fragment file. (This is done using String::trim) This can be useful if your editor inserts an extra newline at the end of files.

As with the document template, the file needs to be in the same directory as the code.

    {{ (0..self.value).map(|v| format!("{}", v)) }}

The fragment can now be used inside another fragment or document.


Licensed under either of


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~70K SLoC