Crate srtemplate

source ·
Expand description

The library features are specified in your Cargo.toml file.

  • text: Text processing functions.
  • os: Functions related to the operating system.
  • math: Mathematical functions.
  • typed_args: Enables typed arguments, if specified.
  • debug: Enable log for library
  • default: Enable all features excepts debug feature

To enable specific features, you can include them in your dependencies, like:

srtemplate = { version = "0.1", default-features = false, features = ["text", "os"] }

Make sure to include the required features you need in your application.


use srtemplate::SrTemplate;

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());

To see all function implemented for template syntax see wiki




  • Re-exports the SrTemplateError type for convenient use. Collection of errors in the library

Type Aliases§