This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.

Template

~import std/template

Template Library - Code Pattern Templates for Transforms

template.kz · 1 tors · ~[comptime]

Template Library - Code Pattern Templates for Transforms · 25 more lines
Template Library - Code Pattern Templates for Transforms Allows defining reusable code patterns that transforms can instantiate inline. Templates are stored in the AST and looked up by name at compile time. Usage: std/template:define(name: "if") [template]{ if (${condition}) { ${| then |} } else { ${| else |} } } In a transform: const template = template_utils.lookupTemplate(ast, "if"); const code = template_utils.interpolate(template, bindings); Placeholder syntax (uses ${} to avoid conflicts with Zig braces): ${name} - substitute with named binding value ${| branch |} - inline the continuation code for this branch Define a named template with source code pattern [norun] means it doesn't execute - just stores data in AST for later lookup

define

comptimenorun koru_std/template.kz:27