lux.macro a LUX module
A module that provides a macro processor
Functions
-
process (str, env)
-
Processes the given string expanding the macros.
There are two kinds of
expanded macros:
- Lines starting with
#
: the whole line is inserted in the generator code - Expressions wrapped in
$(…)
: the expression is inserted into that part of the string
The implementation is based on this article.
Parameters:
Returns:
-
string
The expanded string
Usage:
local macro = require 'lux.macro' local expanded = macro.process("the answer is $(6*x)", { x = 7 }) assert(expanded == "the answer is 42")
- Lines starting with