Модуль:GetField: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| (не показано 7 промежуточных версий этого же участника) | |||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local lang = mw.language.getContentLanguage() | |||
local JsonPaths = require('Module:JsonPaths') | local JsonPaths = require('Module:JsonPaths') | ||
| Строка 363: | Строка 364: | ||
local templatePath = tplPath | local templatePath = tplPath | ||
if project ~= nil and project ~= "" then | if project ~= nil and project ~= "" then | ||
templatePath = | templatePath = project .. ":" .. lang:ucfirst(tplPath) | ||
templatePath = "{{#ifexist:Шаблон:" .. templatePath .. "|" .. templatePath .. "|" .. tplPath .. "}}" | templatePath = "{{#ifexist:Шаблон:" .. templatePath .. "|" .. templatePath .. "|" .. tplPath .. "}}" | ||
end | end | ||
local tplStr = "{{" .. templatePath .. "|id=" .. tostring(id) | local tplStr = "{{Шаблон:" .. templatePath .. "|id=" .. tostring(id) | ||
if extra ~= "" then | if extra ~= "" then | ||
tplStr = tplStr .. "|" .. extra | tplStr = tplStr .. "|" .. extra | ||
| Строка 843: | Строка 844: | ||
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 "") | ||
if jsonStr == "" or tplPath == "" then | if jsonStr == "" or tplPath == "" then | ||
return "" | return "" | ||
| Строка 853: | Строка 855: | ||
local okDp, dp = pcall(require, "Module:GetField") | local okDp, dp = pcall(require, "Module:GetField") | ||
local calls = {} | |||
local | local projectPath = nil | ||
if project ~= nil and project ~= "" then | |||
projectPath = project .. ":" .. lang:ucfirst(tplPath) | |||
end | |||
local function makeTemplatePrefix() | |||
if projectPath then | |||
return "{{Шаблон:{{#ifexist:Шаблон:" .. projectPath .. "|" .. projectPath .. "|" .. tplPath .. "}}" | |||
end | |||
return "{{" .. tplPath | |||
end | |||
local function makeCall(id, obj) | local function makeCall(id, obj) | ||
| Строка 861: | Строка 875: | ||
end | end | ||
local parts = { | local parts = { makeTemplatePrefix(), "id=" .. id } | ||
if type(obj) == "table" then | if type(obj) == "table" then | ||