I worked on this project in deep background for a while, and finally found time to polish it a little bit and push to github/PyPI. The idea is to have lightweight, memory-efficient, unbloated template engine for MicroPython. Unbloated means there's no template interpreter - why to have it, if there's already interpreter in MicroPython, just need to convert template to Python source, voila. Memory-efficient means that partial chunk-by-chunk template rendering should be supported, so template is compiled into a generator function.
Quick start:
Code: Select all
git clone https://github.com/pfalcon/utemplate
cd utemplate/examples
micropython ../utemplate_util.py run squares.tpl
Example of template:
Code: Select all
{% args %}
{% for i in range(5) %}
| {{i}} | {{"%2d" % i ** 2}} |
{% endfor %}
Output:
Code: Select all
| 0 | 0 |
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |