Type: nodetool.text.Template
Namespace: nodetool.text
Description
Uses Jinja2 templating to format strings with variables and filters. This node is dynamic and can be used to format text with dynamic inputs. text, template, formatting, format, combine, concatenate, +, add, variable, replace, filter
Use cases:
- Generating personalized messages with dynamic content
- Creating parameterized queries or commands
- Formatting and filtering text output based on variable inputs
Examples:
- text: "Hello, {{ name }}!"
- text: "Title: {{ title|truncate(20) }}"
- text: "Name: {{ name|upper }}"
Available filters:
- truncate(length): Truncates text to given length
- upper: Converts text to uppercase
- lower: Converts text to lowercase
- title: Converts text to title case
- trim: Removes whitespace from start/end
- replace(old, new): Replaces substring
- default(value): Sets default if value is undefined
- first: Gets first character/item
- last: Gets last character/item
- length: Gets length of string/list
- sort: Sorts list
- join(delimiter): Joins list with delimiter
Properties
| Property | Type | Description | Default |
|---|---|---|---|
| string | str |
Examples:
- text: "Hello, {{ name }}!"
- text: "Title: {{ title|truncate(20) }}"
- text: "Name: {{ name|upper }}"
Available filters:
- truncate(length): Truncates text to given length
- upper: Converts text to uppercase
- lower: Converts text to lowercase
- title: Converts text to title case
- trim: Removes whitespace from start/end
- replace(old, new): Replaces substring
- default(value): Sets default if value is undefined
- first: Gets first character/item
- last: Gets last character/item
- length: Gets length of string/list
- sort: Sorts list
- join(delimiter): Joins list with delimiter | `` | | values | `any` |
The values to replace in the string.
- If a string, it will be used as the format string.
- If a list, it will be used as the format arguments.
- If a dictionary, it will be used as the template variables.
- If an object, it will be converted to a dictionary using the object's **dict** method.
| `{}` |
Outputs
| Output | Type | Description |
|---|---|---|
| output | str |
Metadata
Related Nodes
Browse other nodes in the nodetool.text namespace.