Module pl.template
A template preprocessor.
Originally by Ricki Lake
There are two rules:
- lines starting with # are Lua
- otherwise, `$(expr)` is the result of evaluating `expr`
# for i = 1,3 do $(i) Hello, Word! # endOther escape characters can be used, when the defaults conflict with the output language.
> for _,n in pairs{'one','two','three'} do static int l_${n} (luaState *state); > endSee the Guide.
Functions
substitute (str, env) | expand the template using the specified environment. |
Functions
- substitute (str, env)
-
expand the template using the specified environment.
Parameters:
str
: the template stringenv
: the environment (by default empty).
There are three special fields in the environment table_parent
continue looking up in this table_brackets
; default is '()', can be any suitable bracket pair_escape
; default is '#'