Conditional substring in a Jinja2 template
There is a nicer "oneliner": {{ name | regex_replace('-p$','') }}
.
Found it.
If anyone wants to know:
{% if name.endswith('-p') %}
{{ name[:-2] }}
{% else %}
{{ name }}
{% endif %}
For simple substring ...
"{{var_name[start:end]}}"
where start is starting position (offset 0) and end is end position (offset 1) ... it seems!
The title of this question suggests just wanting to get a substring from a variable. And most other search results have similar titles but then give a specific response like splitting paths etc. This is for those of you that, like me, had trouble finding such a basic thing.