From 0a98dfec80d37a3c65b656ad7efeca02536a7736 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 12 Sep 2018 12:44:39 +0200 Subject: [PATCH] template: allow aliasing escape funcs --- template.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/template.lua b/template.lua index 78493f1..4f64866 100644 --- a/template.lua +++ b/template.lua @@ -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