Closed mesztam closed 8 months ago
Can you elaborate on your question with an example of what you want as output and some code?
I tested this with pystache and partials are escaped:
context =\
{
'users' : [
{'name': 'John',
'job' : 'Engineer'},
{'name': 'Leo',
'job' : 'Coder<br>'}
]
}
full_template =\
'''
{{#users}}
{{name}} is an {{job}}
{{/users}}
'''
renderer = pystache.Renderer()
output = renderer.render(full_template, context)
print(output)
The above produces:
John is an Engineer
Leo is an Coder<br>
With partials:
base_template =\
'''
{{#users}}
{{> user}}
{{/users}}
'''
print("The same data now as a partial with a path:\n")
output = renderer.render(base_template, context)
print(output)
user.mustache:
{{name}} is an {{job}}
Produces:
John is an Engineer
Leo is an Coder<br>
The spec does not state whether partials should be escaped or not. Some implementations do, some don't. Some might have a triple-mustache variant of every tag type so each can be either escaped or not escaped.
If you believe that something should be standardized, you can take it to https://github.com/mustache/spec/discussions.
Closing this, as this repository is only about the Mustache website, not about the template language.
Hi, is there any way to escape the output of a partial? E.g. when using the output of the partial as the value of an attribute like this:
<input type="hidden" value="{{> generateHtml }} "/>
Thanks in advance!