A server-side implementation of the Magery templating library for Python 2 and 3. See the Magery README for template syntax.
In the example directory is a Flask app demonstrating server and client code sharing templates.
pip install magery
import mageryParses templates from filename, returns a dictionary of templates.
If templates is not None it will extend the existing templates
dictionary instead of returning a new one.
templates = magery.compile_templates('./template.html')Render a compiled template using data, and return the output as a
string.
templates = magery.compile_templates('./template.html')
data = {'name': 'world'}
templates['app'].render_to_string(data);Render a compile template using data, and write the result to the IO
stream out.
templates = magery.compile_templates('./template.html')
with open('output.html', 'w', encoding='utf-8') as f:
data = {'name': 'world'}
templates['app'].write(data, f);