Files
wren/test/jinja/map_literal.wren
T
retoor 79ff93c9a2 feat: add pexpect and yaml modules with jinja from-import support
Add new pexpect module for process spawning and interaction, including Spawn class with expect, sendline, and timeout handling. Introduce yaml module for YAML parsing with support for nested structures, lists, and data types. Extend jinja template engine with brace tokenization and FromImportNode for macro imports across templates. Register all new foreign functions in modules.c and include generated demo scripts.
2026-01-25 21:09:29 +00:00

25 lines
745 B
JavaScript
Vendored

// retoor <retoor@molodetz.nl>
import "jinja" for Environment, DictLoader
var tpl1 = "{\x25 set data = {\"name\": \"Alice\", \"age\": 30} \x25}Name: {{ data.name }}, Age: {{ data.age }}"
var tpl2 = "{\x25 set empty = {} \x25}Done"
var tpl3 = "{\x25 set single = {\"key\": \"value\"} \x25}Key: {{ single.key }}"
var loader = DictLoader.new({
"tpl1.html": tpl1,
"tpl2.html": tpl2,
"tpl3.html": tpl3
})
var env = Environment.new(loader)
var result1 = env.getTemplate("tpl1.html").render({})
System.print(result1) // expect: Name: Alice, Age: 30
var result2 = env.getTemplate("tpl2.html").render({})
System.print(result2) // expect: Done
var result3 = env.getTemplate("tpl3.html").render({})
System.print(result3) // expect: Key: value