Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Python Magery

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.

Installation

pip install magery

API

import magery

compile_templates(filename, templates=None)

Parses 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')

Template.render_to_string(data)

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);

Template.write(data, out)

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);

About

Python implementation of Magery templates

Resources

License

Packages

No packages published