Skip to content

Latest commit

 

History

History
67 lines (48 loc) · 995 Bytes

README.md

File metadata and controls

67 lines (48 loc) · 995 Bytes

remplate

Templating that feels Rust-native

Features

  • regular Rust syntax in code blocks
  • support for format!-macro syntax

Usage

// my_template.html

{
    let title = "My Awesome Template";
    let paragraph = "Lorem ipsum etc.";
}

<h1>{ title }</h1>

<p>{ paragraph }</p>

{
    let debug_info = if self.debug_enabled {
        Some("debug is enabled")
    } else {
        None
    };

    debug_info:?
}
// src/main.rs

#[derive(remplate::Remplate)]
#[remplate(path = "my_template.html")]
struct MyTemplate {
    debug_enabled: bool,
}


fn main() {
    println!(
        "{}",
        MyTemplate {
            debug_enabled: true
        }
    );
}
~/remplate-example: cargo run
   Compiling remplate-example v0.1.0 (/home/user/remplate-example)
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/remplate-example`


<h1>My Awesome Template</h1>

<p>Lorem ipsum etc.</p>

Some("debug is enabled")