Модуль:Песочница/Pok/2: различия между версиями
Материал из Space Station 14 Вики
< Модуль:Песочница | Pok
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local | local data = mw.loadData('Module:Песочница/Pok/3') | ||
local function | local function key() | ||
local t = mw.title.getCurrentTitle() | local t = mw.title.getCurrentTitle() | ||
return t and t.prefixedText or nil | |||
end | end | ||
function p.set(frame) | function p.set(frame) | ||
local args = | local args = frame.args or {} | ||
local | local v = args.path or args[1] or args.base or "" | ||
v = mw.text.trim(tostring(v or "")) | |||
local k = key() | |||
if k and v ~= "" then | |||
if | data[k] = v | ||
end | |||
return "" | return "" | ||
end | end | ||
function p.get( | function p.get() | ||
local key | local k = key() | ||
if not | if not k then return nil end | ||
return | return data[k] | ||
end | end | ||
return p | return p | ||
Текущая версия от 05:32, 18 марта 2026
Для документации этого модуля может быть создана страница Модуль:Песочница/Pok/2/doc
local p = {}
local data = mw.loadData('Module:Песочница/Pok/3')
local function key()
local t = mw.title.getCurrentTitle()
return t and t.prefixedText or nil
end
function p.set(frame)
local args = frame.args or {}
local v = args.path or args[1] or args.base or ""
v = mw.text.trim(tostring(v or ""))
local k = key()
if k and v ~= "" then
data[k] = v
end
return ""
end
function p.get()
local k = key()
if not k then return nil end
return data[k]
end
return p