Changeset

10348:3852fc91b2fc 0.11

util.interpolation: Support unescaped variables with more modifiers (fixes #1452) Tests will be added in trunk.
author Kim Alvefur <zash@zash.se>
date Sun, 20 Oct 2019 20:52:14 +0200
parents 10341:4e406944ff85
children 10349:ddddda2896fd 10384:94c9c574cd8a
files util/interpolation.lua
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/util/interpolation.lua	Sun Oct 20 01:20:11 2019 +0200
+++ b/util/interpolation.lua	Sun Oct 20 20:52:14 2019 +0200
@@ -32,7 +32,7 @@
 		-- assert(type(values) == "table", "bad argument #2 to 'render' (table expected)");
 		return (s_gsub(template, pat, function (block)
 			block = s_sub(block, 2, -2);
-			local name, opt, e = s_match(block, "^([%a_][%w_.]*)(%p?)()");
+			local name, raw, opt, e = s_match(block, "^([%a_][%w_.]*)(!?)(%p?)()");
 			if not name then return end
 			local value = values[name];
 			if not value and name:find(".", 2, true) then
@@ -45,7 +45,7 @@
 			if funcs then
 				while value ~= nil and opt == '|' do
 					local f;
-					f, opt, e = s_match(block, "^([%a_][%w_.]*)(%p?)()", e);
+					f, raw, opt, e = s_match(block, "^([%a_][%w_.]*)(!?)(%p?)()", e);
 					f = funcs[f];
 					if f then value = f(value); end
 				end
@@ -70,7 +70,7 @@
 				if type(value) ~= "string" then
 					value = tostring(value);
 				end
-				if opt ~= '!' then
+				if raw ~= '!' then
 					return escape(value);
 				end
 				return value;