Is it possible to extent the Template strings so I can add methods to the identifier:
By default I can replace simple variables:
from string import Template
t = Template("${noun}ification")
t.substitute(dict(noun='Egg')) # Output: 'Eggification'
But I wish to extend the identifier with a custom method (e.g. as_b):
t = Template("${noun.as_b}ification") # Desired output: '<b>Egg</b>ification'
I know I can easily do something similar with Formatted string literals but is it possible using the Template strings, like above? I cannot use Formatted string literals because it will not work inside a script, a JSON file or whatever text that contain curly braces.
Essentially I'm looking for something that can offer the Template strings syntax within the Formatted string literals flexibility.
tasTemplate("<b>${noun}</b>ification")?nounsis a list, I can writeTemplate("${nouns.as_ul}"); then the output is a big unordered list. Imagine${nouns.as_ul}inside an HTML template, I don't need some weird{% for n in nouns %}<li>{{ n }}</li>{% endfor %}but the methodas_ultake care of it, nice and clean.