Skip to main content
Version: 0.10

template

execute

execute(template: str, data: {str:any} = {}) -> str

Applies a parsed template to the specified data object and returns the string output. See https://handlebarsjs.com/ for more documents and examples.

import template

content = template.execute("""\
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{/if}}
</div>
""", {
author: True,
firstName: "Yehuda",
lastName: "Katz",
})

html_escape

html_escape(data: str) -> str

Replaces the characters &"<> with the equivalent html / xml entities.


import template

content = template.html_escape("""\
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{/if}}
</div>
""")