10 releases

0.3.3 Apr 5, 2025
0.3.2 Feb 5, 2025
0.3.1 Dec 27, 2024
0.3.0 Apr 1, 2024
0.2.5 Oct 22, 2023

#213 in Template engine

Download history 110/week @ 2025-10-07 50/week @ 2025-10-14 25/week @ 2025-10-21 3/week @ 2025-10-28 108/week @ 2025-11-04 208/week @ 2025-11-11 149/week @ 2025-11-18 35/week @ 2025-11-25 36/week @ 2025-12-02 24/week @ 2025-12-09 76/week @ 2025-12-16 56/week @ 2025-12-23 101/week @ 2025-12-30 282/week @ 2026-01-06 18/week @ 2026-01-13 152/week @ 2026-01-20

572 downloads per month
Used in grow-rs

MIT/Apache

67KB
1K SLoC

srtemplate

GitHub Workflow Status (with event) Crates.io docs.rs

SrTemplate

Mr. strings template is a library that allows you to render just text templates.

  • You can see a real example here, it is a real time template renderer.
  • Documentation here
  • Wiki

Features

  • Super fast
  • Efficient
  • Renders variables of all types
  • Function system
  • Easy implementation of custom functions
  • Minimum possible dependencies
  • Feature-based implementations, use only what you need
  • Using the same variables renders multiple times

Basic example

[!NOTE] See more examples here

use srtemplate::SrTemplate;

fn main() {
    let mut ctx = SrTemplate::default();
    ctx.add_variable("var", &"World");
    ctx.add_variable("otherVar", &"Other");
    ctx.add_variable("number", &85u8);
    
    let template = "Hello {{ var }}! This is {{ otherVar }} and this is number: {{number}}";
    println!("Rendered: {}", ctx.render(template).unwrap());
}

[!NOTE] For more information about the functions implemented by default or how to use the library in depth, see the wiki

TODO's

  • I would like to change the way custom functions are implemented.
  • Macros to create custom functions
  • Better add_variable function to make more easy and performance managing Cow

Dependencies

~1.3–2MB
~36K SLoC