From e00d066f7a7cb1ffd8df94d90e16565c3dedeec7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 14 Jul 2013 10:01:25 +0200 Subject: sync with Context as of 2013-07-14 --- lualibs-util-tpl.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lualibs-util-tpl.lua') 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 -- cgit v1.2.3