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
  • macros: Enable a easy way to create custom functions
  • default: Enable all features excepts debug feature

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

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

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

§Example

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

Modules§

builtin
The builtin module provides a set of built-in functions for SrTemplate.
function
Re-exports the template::function, template::SrTemplate, [template::TemplateFunction] type for convenient use.
helper
The helper module contains utility functions and traits, and it’s available when the typed_args feature is enabled.
prelude
The prelude module re-exports common items for easier use of SrTemplate.

Structs§

SrTemplate
Re-exports the template::function, template::SrTemplate, [template::TemplateFunction] type for convenient use. This structure is the basis of everything, it is responsible for managing variables and functions.

Enums§

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

Traits§

Variable

Type Aliases§

Function
Re-exports the template::function, template::SrTemplate, [template::TemplateFunction] type for convenient use. This corresponds to the type for custom functions that may exist.

Attribute Macros§

function
Function Macro Documentation

Derive Macros§

Variable
Variable Derive Macro Documentation