5,641
edits
(Update package: OSW Core) |
(Update package: OSW Core) |
||
Line 163: | Line 163: | ||
local string_list = "" | local string_list = "" | ||
for i,e in pairs(v) do | for i,e in pairs(v) do | ||
local eval_template = nil | |||
local eval_templates = p.defaultArgPath(jsonschema, {"properties", k, "items", p.keys.template}, {}) | |||
if (eval_templates[1] == nil) then eval_templates = {eval_templates} end --ensure list of objects | |||
for i, t in pairs(eval_templates) do | |||
if (t[p.keys.mode] ~= nil and t[p.keys.mode] == mode) then eval_template = t --use only render templates in render mode and store templates in store mode | |||
elseif (t[p.keys.mode] == nil) then eval_template = t --default | |||
elseif (debug) then msg = msg .. "Ignore eval_template" .. mw.dumpObject( t ) .. "\n<br>" | |||
end | |||
end | |||
if type(e) == 'table' then | if type(e) == 'table' then | ||
local sub_res = p.expandEmbeddedTemplates({frame=frame, jsondata=e, jsonschema=p.defaultArgPath(jsonschema, {"properties", k, "items"}, {}), template=eval_template, mode=mode, stringify_arrays=stringify_arrays}) | local sub_res = p.expandEmbeddedTemplates({frame=frame, jsondata=e, jsonschema=p.defaultArgPath(jsonschema, {"properties", k, "items"}, {}), template=eval_template, mode=mode, stringify_arrays=stringify_arrays}) | ||
msg = msg .. sub_res.debug_msg | msg = msg .. sub_res.debug_msg | ||
Line 182: | Line 185: | ||
end | end | ||
else | else | ||
if (eval_template ~= nil and eval_template["value"] ~= nil) then | |||
--evaluate single array item string as json {"self": "<value>", ".": "<value>"} | |||
local sub_res = p.expandEmbeddedTemplates({frame=frame, jsondata={["self"]=e,["."]=e}, jsonschema=p.defaultArgPath(jsonschema, {"properties", k, "items"}, {}), template=eval_template, mode=mode, stringify_arrays=stringify_arrays}) | |||
mw.logObject(sub_res) | |||
e = sub_res.res | |||
v[i] = e | |||
end | |||
if (stringify_arrays) then string_list = string_list .. e .. ";" end | if (stringify_arrays) then string_list = string_list .. e .. ";" end | ||
end | end |