Module:Template input parse: Difference between revisions
kv pairs returns nil if the string was empty |
Bugfix with parsing kv-pairs |
||
Line 104: | Line 104: | ||
-- Then tokenize the tokens into key-value pairs | -- Then tokenize the tokens into key-value pairs | ||
local pairs_ = {} | local pairs_ = {} | ||
local num_pairs = 0 | |||
for i = 1, #parsed do | for i = 1, #parsed do | ||
local pair = p.parse_pair(parsed[i]) | local pair = p.parse_pair(parsed[i]) | ||
if pair ~= nil and #pair == 2 then | if pair ~= nil and #pair == 2 then | ||
pairs_[pair[1]] = pair[2] | pairs_[pair[1]] = pair[2] | ||
num_pairs = num_pairs + 1 | |||
end | end | ||
end | end | ||
if | |||
if num_pairs == 0 then | |||
return nil | return nil | ||
else | else |