template: allow aliasing escape funcs

This commit is contained in:
Daniel Kolesa 2018-09-12 12:44:39 +02:00
parent 39b5177dcd
commit 0a98dfec80
1 changed files with 11 additions and 3 deletions

View File

@ -294,14 +294,22 @@ local make_stream = function(str)
end
end
local esc_def = function(str)
return str
end
local escapes = {
["default"] = function(str)
return str
end
["default"] = esc_def
}
M.set_escape = function(style, func)
local old = escapes[style]
if type(func) == "string" then
func = escapes[func]
end
if not func then
func = esc_def
end
escapes[style] = func
return old
end