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 librarymacros: Enable a easy way to create custom functionsdefault: Enable all features exceptsdebugfeature
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
builtinmodule provides a set of built-in functions forSrTemplate. - function
- Re-exports the
template::function,template::SrTemplate, [template::TemplateFunction] type for convenient use. - helper
- The
helpermodule contains utility functions and traits, and it’s available when thetyped_argsfeature is enabled. - prelude
- The
preludemodule re-exports common items for easier use ofSrTemplate.
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
SrTemplateErrortype for convenient use. Collection of errors in the library
Traits§
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