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 librarydefault
: Enable all features exceptsdebug
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§
- The
builtin
module provides a set of built-in functions forSrTemplate
. - Re-exports the
template::function
,template::SrTemplate
,template::TemplateFunction
type for convenient use. - The
helper
module contains utility functions and traits, and it’s available when thetyped_args
feature is enabled. - The
prelude
module re-exports common items for easier use ofSrTemplate
.
Structs§
- 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§
- Re-exports the
SrTemplateError
type for convenient use. Collection of errors in the library
Type Aliases§
- Re-exports the
template::function
,template::SrTemplate
,template::TemplateFunction
type for convenient use. This corresponds to the type for custom functions that may exist.