Truncate is not working on this {% text “Sub-Headline”|truncate(40) %}
What am I doing wrong?
Truncate is not working on this {% text “Sub-Headline”|truncate(40) %}
What am I doing wrong?
what are you trying to do?
HubL module markup has an anatomy:
Red
= module type
Blue
= system name
Green
= editor label
Orange
= Value{% text "simple_text_field" label="Enter text here", value="This is the default value for this text field" %}
Truncate is used to trim a set of characters to a specific number, in your case 40. You are essentially creating a text module, giving it a system label of “Sub-Headline”, and then truncating the system name. This might be working by truncating the system name in the database, but we’ll never know because you don’t have access to the database containing the modules you create in your portal. Is that what you are trying to do?
If you are wanting to truncate the value of the text module you can do this:
{% text "system-name" label="editor-label", value="The initial value"|truncate(12) %}
The value of the above module will be cut off after 12 characters. I’ve never used a filter inside of a module snippet like this before, so if it doesn’t work try exporting it to the template:
{% text "system-name" label="editor-label", value="The initial value", export_to_template_context=True %}
and then using truncate on the data token:
{{ widget_data.system-name.value|truncate(12) }}