Crates.io | trillium-ructe |
lib.rs | trillium-ructe |
version | 0.4.0 |
source | src |
created_at | 2021-07-26 00:04:00.789104 |
updated_at | 2022-02-09 01:46:06.258678 |
description | ructe templates for trillium.rs |
homepage | |
repository | https://github.com/prabirshrestha/trillium-ructe |
max_upload_size | |
id | 427212 |
size | 22,456 |
ructe templates for trillium.rs.
[package]
name = "example-ructe-template"
edition = "2018"
build = "src/build.rs"
[dependencies]
trillium = "0.3.0"
trillium-ructe = "0.3.0"
trillium-smol = "0.3.0"
[build-dependencies]
ructe = { version = "0.13.4", features = ["sass"] }
use ructe::{Result, Ructe};
fn main() -> Result<()> {
let mut ructe = Ructe::from_env()?;
let mut statics = ructe.statics()?;
statics.add_files("static")?;
statics.add_sass_file("styles/style.scss")?;
ructe.compile_templates("templates")?;
Ok(())
}
@(text: &str)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Trillium Ructe Example</title>
</head>
<body>
<h1>@text</h1>
</body>
</html>
use trillium::Conn;
use trillium_ructe::RucteConnExt;
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
fn main() {
trillium_smol::run(|conn: Conn| async move {
conn.render_html(|o| templates::helloworld(o, "html"))
});
}
Use conn.render_html
to render html or conn.render
to render raw template.