Module pl.template

A template preprocessor.

Originally by [Ricki Lake](http://lua-users.org/wiki/SlightlyLessSimpleLuaPreprocessor)

There are two rules:

* lines starting with # are Lua * otherwise, `$(expr)` is the result of evaluating `expr`

Example:

# for i = 1,3 do $(i) Hello, Word! # end ===> 1 Hello, Word! 2 Hello, Word! 3 Hello, Word!

Other 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); > end

See the Guide.

Dependencies: `pl.utils`

Functions

substitute (str[, env]) expand the template using the specified environment.


Functions

substitute (str[, env])
expand the template using the specified environment. There are three special fields in the environment table `env`

* `_parent` continue looking up in this table (e.g. `_parent=_G`) * `_brackets`; default is '()', can be any suitable bracket pair * `_escape`; default is '#'

Parameters:

  • str string the template string
  • env tab the environment (optional)
generated by LDoc 1.4.3 Last updated Tue, 18 Aug 2015 11:21:53 +0200