Comparison

util/interpolation.lua @ 11306:5798ab735619 0.11

util.interpolation: Fix combination of filters and fallback values #1623
author Kim Alvefur <zash@zash.se>
date Mon, 25 Jan 2021 20:58:11 +0100
parent 10348:3852fc91b2fc
child 11307:f2e276bb4ef8
comparison
equal deleted inserted replaced
11266:2115496e8251 11306:5798ab735619
41 value = value[word]; 41 value = value[word];
42 if not value then break; end 42 if not value then break; end
43 end 43 end
44 end 44 end
45 if funcs then 45 if funcs then
46 while value ~= nil and opt == '|' do 46 while opt == '|' do
47 local f; 47 local f;
48 f, raw, opt, e = s_match(block, "^([%a_][%w_.]*)(!?)(%p?)()", e); 48 f, raw, opt, e = s_match(block, "^([%a_][%w_.]*)(!?)(%p?)()", e);
49 f = funcs[f]; 49 f = funcs[f];
50 if f then value = f(value); end 50 if value ~= nil and f then value = f(value); end
51 end 51 end
52 end 52 end
53 if opt == '#' or opt == '%' then 53 if opt == '#' or opt == '%' then
54 if type(value) ~= "table" then return ""; end 54 if type(value) ~= "table" then return ""; end
55 local iter = opt == '#' and ipairs or pairs; 55 local iter = opt == '#' and ipairs or pairs;