mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
Changelog since 1.3.0: - Fix escaped percent signs (%%) not rendering correctly when not at line beginnings (1.3.1/1.3.2) - Add 'pass' statements to empty control blocks to prevent errors (1.3.3) - Fix strict_undefined mode conflicts with comprehensions inside function definitions (1.3.3) - Revert dictionary literal parsing changes that caused bracketed expression regressions (1.3.5) Full changelog: https://docs.makotemplates.org/en/latest/changelog.html Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
29 lines
578 B
Bash
29 lines
578 B
Bash
#!/bin/sh
|
|
|
|
[ "$1" = python3-mako ] || exit 0
|
|
|
|
python3 - << 'EOF'
|
|
from mako.template import Template
|
|
|
|
# Basic variable rendering
|
|
t = Template("Hello, ${name}!")
|
|
result = t.render(name="World")
|
|
assert result == "Hello, World!", f"Unexpected: {result!r}"
|
|
|
|
# Control flow
|
|
t = Template("""
|
|
% for item in items:
|
|
- ${item}
|
|
% endfor
|
|
""".strip())
|
|
result = t.render(items=["a", "b", "c"])
|
|
assert "- a" in result
|
|
assert "- b" in result
|
|
assert "- c" in result
|
|
|
|
# Expression evaluation
|
|
t = Template("${2 + 2}")
|
|
result = t.render()
|
|
assert result.strip() == "4", f"Unexpected: {result!r}"
|
|
EOF
|