#askama #camel-case #txt #file #strong-typing #anvil-askama

anvil-askama

Anvil wrapper for the askama templating library

4 releases

new 0.2.2 Apr 12, 2025
0.2.1 Apr 12, 2025
0.1.1 Apr 4, 2025
0.1.0 Apr 2, 2025

#289 in Template engine

Download history 392/week @ 2025-04-01 419/week @ 2025-04-08

811 downloads per month

MIT license

69KB
713 lines

anvil-askama

An Anvil integration for Askama templates.

Installation

[dependencies]
anvil-askama = "0.2.1"
anvil = "0.3.0"
askama = "0.13.0"

Usage

use anvil::Forge;
use anvil_askama::prelude::*;  // Import extension traits and functions
use askama::Template;

// Define an Askama template
#[derive(Template)]
#[template(source = "Hello, {{ name }}!", ext = "txt")]
struct MyTemplate {
    name: String,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let template = MyTemplate { name: "World".to_string() };
    
    // Generate a new file
    generate(&template).forge("hello.txt")?;
    
    // Append to an existing file
    append(&template).forge("log.txt")?;
    
    Ok(())
}

Dependencies

~1.5–2.2MB
~54K SLoC