diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-07-14 10:01:25 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-07-14 10:01:25 +0200 |
commit | e00d066f7a7cb1ffd8df94d90e16565c3dedeec7 (patch) | |
tree | c9893c780ccc05c8f5402b8bf09caf361cbeea86 /lualibs-util-tpl.lua | |
parent | f2f35fe3d8a1c5ce74ddbb8eef3cad2b18a379dc (diff) | |
download | lualibs-e00d066f7a7cb1ffd8df94d90e16565c3dedeec7.tar.gz |
sync with Context as of 2013-07-14
Diffstat (limited to 'lualibs-util-tpl.lua')
-rw-r--r-- | lualibs-util-tpl.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lualibs-util-tpl.lua b/lualibs-util-tpl.lua index dcc4c12..e0c405a 100644 --- a/lualibs-util-tpl.lua +++ b/lualibs-util-tpl.lua @@ -159,6 +159,14 @@ end templates.replace = replace +function templates.replacer(str,how,recurse) -- reads nicer + return function(mapping) + return lpegmatch(replacer,str,1,mapping,how or "lua",recurse or false) or str + end +end + +-- local cmd = templates.replacer([[foo %bar%]]) print(cmd { bar = "foo" }) + function templates.load(filename,mapping,how,recurse) local data = io.loaddata(filename) or "" if mapping and next(mapping) then |