Skip to main content

Very lightweight, memory-efficient (uses generator protocol), dependency-free template engine (compiles to Python source). Particularly well suited for usage with MicroPython.org

Project description

utemplate is lightweight and memory-efficient template engine for Python, primarily intended for usage with MicroPython (https://github.com/micropython/micropython).

utemplate syntax is roughly based on Django/Jinja2 syntax (e.g. “{% if %}”), but only the most needed features are offered (for example, “filters” are syntactic sugar for function calls, and so far not planned for implementation).

utemplates compiles templates to Python source code, specifically to a generator function which, being iterated over, produces consecutive parts (substrings) of a rendered template. This allows for minimal memory usage during template substitution (with MicroPython, it starts from mere hundreds of bytes). Generated Python code can be imported as a module directly, or simple loader class is provided for convenience. There is also loader class which will compile templates on the fly, if not already compiled (currently not automatically recompiled if changed, this is on TODO).

See examples/ directory for examples and supported features.

To test/manage templates, “utemplate_util.py” tool is provided. For example, to quickly try a template (assuming you are already in “examples/” dir):

micropython ../utemplate_util.py run squares.tpl

or

python3 ../utemplate_util.py run squares.tpl

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utemplate-0.9.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file utemplate-0.9.tar.gz.

File metadata

  • Download URL: utemplate-0.9.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for utemplate-0.9.tar.gz
Algorithm Hash digest
SHA256 652fde6eb15dd2dcdaa8cc2ad8e8dd86859f56f0d9cc0a00107aa958ff598c7a
MD5 420f9cd48814eb9fb410b937e8f47027
BLAKE2b-256 a93c459213aafc66db142315ddd764469a32df7f2cf608cccb1d9e14347681a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page