Модуль:Сущность/data: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 697: | Строка 697: | ||
end | end | ||
local function each_entity_data(frame, id, onEntity, onMissing) | local function has_matching_keys(parsed, filter) | ||
if not filter or not filter.hasWhitelist then | |||
return true | |||
end | |||
if type(parsed) ~= "table" then | |||
return false | |||
end | |||
for _, sw in ipairs(switchModeOrder) do | |||
local mode = switchModeRegistry[sw] or {} | |||
local keys | |||
if type(mode.get_keys) == "function" then | |||
keys = mode.get_keys(parsed) | |||
else | |||
keys = parsed[sw] or {} | |||
end | |||
if type(keys) == "table" then | |||
for _, key in ipairs(keys) do | |||
if should_include_key(filter, sw, key) then | |||
return true | |||
end | |||
end | |||
end | |||
end | |||
if type(parsed.cardTag) == "string" and parsed.cardTag ~= "" then | |||
if should_include_key(filter, "card", "cardTag") then | |||
return true | |||
end | |||
end | |||
return false | |||
end | |||
local function each_entity_data(frame, id, onEntity, onMissing, keyFilter) | |||
local componentWhitelist = frame.args.componentWhitelist or frame.args.componentwhitelist or "" | local componentWhitelist = frame.args.componentWhitelist or frame.args.componentwhitelist or "" | ||
local componentBlacklist = frame.args.componentBlacklist or frame.args.componentblacklist or "" | local componentBlacklist = frame.args.componentBlacklist or frame.args.componentblacklist or "" | ||
| Строка 741: | Строка 777: | ||
end | end | ||
local needsExtra = has_matching_keys(parsed, keyFilter) | |||
local extra = "" | local extra = "" | ||
local paramNames = get_template_params(tplPath, content) | if needsExtra and dp then | ||
local paramNames = get_template_params(tplPath, content) | |||
local dataPage = tplPath .. ".json" | local dataPage = tplPath .. ".json" | ||
extra = get_selective_extra(id, dataPage, paramNames) | extra = get_selective_extra(id, dataPage, paramNames) | ||
| Строка 915: | Строка 952: | ||
errors[#errors + 1] = build_missing_template_error(kind, name, isStore, tplPath) | errors[#errors + 1] = build_missing_template_error(kind, name, isStore, tplPath) | ||
end | end | ||
end) | end, filter) | ||
if not ok then return "" end | if not ok then return "" end | ||