Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/myfavshrimp/remplate

Experiments with compile-time templating
https://github.com/myfavshrimp/remplate

Last synced: about 2 months ago
JSON representation

Experiments with compile-time templating

Awesome Lists containing this project

README

        

# remplate

Templating that feels Rust-native

## Features

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

## Usage

```rust
// my_template.html

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

{ title }

{ paragraph }

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

debug_info:?
}
```

```rust
// src/main.rs

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

fn main() {
println!(
"{}",
MyTemplate {
debug_enabled: true
}
);
}
```

```html
~/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`

My Awesome Template

Lorem ipsum etc.

Some("debug is enabled")
```