Модуль:GetField: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 446: | Строка 446: | ||
return templatePath | return templatePath | ||
end | end | ||
local function split_template_spec(tplPath, tplArgs) | local function split_template_spec(tplPath, tplArgs) | ||
tplPath = mw.text.unstripNoWiki(tplPath or "") | tplPath = mw.text.unstripNoWiki(tplPath or "") | ||
tplArgs = | tplArgs = mw.text.unstripNoWiki(tplArgs or "") | ||
if tplArgs ~= "" and string.sub(tplArgs, 1, 1) == "|" then | |||
tplArgs = string.sub(tplArgs, 2) | |||
end | |||
if tplArgs == "" then | if tplArgs == "" then | ||
local pipePos = string.find(tplPath, "|", 1, true) | local pipePos = string.find(tplPath, "|", 1, true) | ||
if pipePos then | if pipePos then | ||
tplArgs = | tplArgs = mw.text.unstripNoWiki(string.sub(tplPath, pipePos + 1)) | ||
if tplArgs ~= "" and string.sub(tplArgs, 1, 1) == "|" then | |||
tplArgs = string.sub(tplArgs, 2) | |||
end | |||
tplPath = string.sub(tplPath, 1, pipePos - 1) | tplPath = string.sub(tplPath, 1, pipePos - 1) | ||
end | end | ||
| Строка 489: | Строка 482: | ||
local entry = resolve_entry(data, id) | local entry = resolve_entry(data, id) | ||
local extra = flatten_entry(entry) | local extra = flatten_entry(entry) | ||
local extraTplArgs = | local extraTplArgs = tplArgs or "" | ||
local templatePath = resolve_template_path(tplPath) | local templatePath = resolve_template_path(tplPath) | ||
| Строка 1047: | Строка 1040: | ||
local jsonStr = mw.text.unstripNoWiki(args[1] or args.json or "") | local jsonStr = mw.text.unstripNoWiki(args[1] or args.json or "") | ||
local tplPath = mw.text.unstripNoWiki(args[2] or args.template or "") | local tplPath = mw.text.unstripNoWiki(args[2] or args.template or "") | ||
local tplArgs = | local tplArgs = args[3] or args.tplArgs or args.templateArgs or "" | ||
tplPath, tplArgs = split_template_spec(tplPath, tplArgs) | tplPath, tplArgs = split_template_spec(tplPath, tplArgs) | ||