Модуль:Песочница/Pok/2: различия между версиями

Нет описания правки
Нет описания правки
 
Строка 1: Строка 1:
local p = {}
local p = {}


local STORE = {}
local data = mw.loadData('Module:Песочница/Pok/3')


local function curKey()
local function key()
     local t = mw.title.getCurrentTitle()
     local t = mw.title.getCurrentTitle()
     if not t then return nil end
     return t and t.prefixedText or nil
    return t.prefixedText
end
end


function p.set(frame)
function p.set(frame)
     local args = frame and frame.args or {}
     local args = frame.args or {}
     local path = args.path or args[1] or args.base or ""
     local v = args.path or args[1] or args.base or ""
     path = mw.text.trim(tostring(path or ""))
     v = mw.text.trim(tostring(v or ""))
     if path == "" then return "" end
     local k = key()
    local key = curKey()
     if k and v ~= "" then
     if not key then return "" end
        data[k] = v
    STORE[key] = path
    end
     return ""
     return ""
end
end


function p.get(frame)
function p.get()
     local key = curKey()
     local k = key()
     if not key then return nil end
     if not k then return nil end
     return STORE[key]
     return data[k]
end
 
function p.clear(frame)
    local key = curKey()
    if key then STORE[key] = nil end
    return ""
end
end


return p
return p