-
-
Notifications
You must be signed in to change notification settings - Fork 3
Template Syntaxis
The syntax of this template library is very simple, but it has some things to take into account
Once the variable is declared with the add_variable
method, it will be available for rendering, the syntax for this is:
{{ variable_name }}
Not supported
{{ variable
or
variable }}
On the functions side, at the moment they only support working with declared variables, the advantage they have is that they can be included recursively
Example:
{{ function(arg1, arg2, arg3) }}
Supports n arguments, and these are processed at rendering time, after parsing.
As mentioned above, it is possible to nest functions recursively, achieving behavior like this
{{ function(trim(arg1, arg2, arg3), add_u8(one, mul_u8(two, three))) }}
The library also provides default functions for certain basic operations, from mathematics to text handling, which are only available by activating certain features
Available with the feature default
or math
Available types: u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, f32, f64
- addition:
add_<type>
- subtraction:
sub_<type>
- multiplication:
mul_<type>
- division:
div_<type>
These functions are declared as follows
fn <operation>_<type>(args: &[String]) -> FuncResult
// Example
fn add_i128(args: &[String]) -> FuncResult
And they are used as follows
Hi, {{ add_i32(one, two) }}
Available with the feature default
or text
- Text to Case
- toLower: requires at least one argument up to n arguments
usage:
toLower(args: &[String]) -> FuncResult
{{ toLower(a, b, c) }}
- toUpper: requires at least one argument up to n arguments
usage:
toUpper(args: &[String]) -> FuncResult
{{ toUpper(a, b, c) }}
- trim: requires at least one argument up to n arguments
usage:
trim(args: &[String]) -> FuncResult
{{ trim(a, b, c) }}
- toLower: requires at least one argument up to n arguments