Render a Template in Larzscript
Fill a string template with dotted variables and a loop - no framework needed for a page, an email body, or a report.
template supports {{dotted.var}} substitution and a for/if pass (Mustache-lite or Jinja-style syntax, your pick), with optional HTML escaping - deliberately single-pass and non-nesting, a small subset rather than a full engine.
larzscript pkg install template
Code
import "template" as template
let t = "Hi {{user.name}}!\n{% for x in items %}- {{x}}\n{% endfor %}"
print(template.render(t, {"user": {"name": "Sam"}, "items": ["bread", "milk"]}))Output
Hi Sam! - bread - milk
Related
larztemplateSimple string templating with dotted variables, loops/conditionals, optional HTML escaping→Make an HTTP GET Request in LarzscriptFetch a URL and read its status code and body - or parse a JSON API response directly.→Sign and Verify a Webhook Payload in LarzscriptSign an outgoing webhook payload with HMAC-SHA256, and verify an incoming one - the same shape real payment/webhook providers use.→Hash Data with SHA-256 in LarzscriptCompute a real SHA-256 hash and an HMAC-SHA256 message authentication code.→