Learn to Code ยท zero-dependency ยท MIT

larztemplate

A tiny template engine.

Every real app builds strings from data - web pages, emails, config. Rather than messy concatenation you use a template. larztemplate is a small but genuine engine - {{ variables }}, {% for %} loops and {% if %} branches - to generate HTML and text cleanly, and to see how templating works.

larzscript pkg install template
View on GitHub →Learn the stack

What you get

Try it

import "template" as template
let t = "Hi {{user.name}}!\n{% for x in items %}- {{x}}\n{% endfor %}{% if vip %}VIP!{% else %}Regular{% endif %}"
print(template.render(t, {"user": {"name": "Sam"}, "items": ["a", "b"], "vip": true}))
print(template.render("{{name}}", {"name": "<b>"}, true))
Output
Hi Sam!
- a
- b
VIP!
&lt;b&gt;

Why it's in the Larz Stack

larztemplate is a real Larzscript package (larzscript pkg install template) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.