Main module
- tmep.parse(template: str, values: Dict[str, Any] | None = None, additional_functions: Dict[str, Callable[[...], str | int]] | None = None, functions: Dict[str, Callable[[...], str | int]] | None = None) str[source]
Parse the given template string and substitute placeholders with values.
- Parameters:
template – The template string to parse, for example
Hello $name!.values – Optional dictionary of values to substitute in the template, for example
{"name": "World"}.additional_functions – Additional functions to use in the template.
functions – Use the given functions instead of the default functions.
- Returns:
The parsed template string with placeholders substituted.
- class tmep.Template(template: str)[source]
Bases:
object- expr: Expression
- interpret(values: Dict[str, Any] = {}, functions: Dict[str, Callable[[...], str | int]] = {}) str[source]
Like substitute, but forces the interpreter (rather than the compiled version) to be used. The interpreter includes exception-handling code for missing variables and buggy template functions but is much slower.
- tmep.Functions