# 02 · template-engine **演示**:`gsub("%${(%w+)}")` 替换 `${name}`,缺失变量变空串。 **运行时**:`lua54`、`luajit`。 **运行**: ```sh .tools/bin/lua54 scripts/run-example.lua examples/34-mini-dsl/02-template-engine .tools/bin/lua54 scripts/test-example.lua examples/34-mini-dsl/02-template-engine ``` **预期输出**(lua 5.4.9 / macOS arm64): ```text text=hello Ada, you are 36 ``` **看点**:模式匹配适合简单模板;复杂语法用解析器。 **注意**:缺失变量应报错还是空串,要写进契约。