模块:Qualityprice:修订间差异
来自星露谷物语扩展百科
更多操作
删除的内容 添加的内容
无编辑摘要 |
无编辑摘要 |
||
| 第5行: | 第5行: | ||
local function expandTemplate(args) |
local function expandTemplate(args) |
||
local templateArgs = {} |
|||
for key, value in pairs(args) do |
for key, value in pairs(args) do |
||
if value ~= "" then |
|||
| ⚫ | |||
if value == "" then |
|||
| ⚫ | |||
end |
end |
||
end |
end |
||
| 第15行: | 第15行: | ||
title = '模板:Qualityprice/Base', |
title = '模板:Qualityprice/Base', |
||
args = { |
args = { |
||
templateArgs[1], |
|||
templateArgs[2], |
|||
pm = |
pm = templateArgs['pm'], |
||
dsv = |
dsv = templateArgs['dsv'], |
||
hide = |
hide = templateArgs['hide'], |
||
quality = |
quality = templateArgs['quality'], |
||
} |
} |
||
} |
} |
||
2024年11月19日 (二) 14:16的版本
local cache = require "mw.ext.LuaCache"
local KEY_PREFIX = "Module:Qualityprice"
local EXP_TIME = 172800
local p = {}
local function expandTemplate(args)
local templateArgs = {}
for key, value in pairs(args) do
if value ~= "" then
templateArgs[key] = value
end
end
mw.logObject(args)
return mw.getCurrentFrame():expandTemplate{
title = '模板:Qualityprice/Base',
args = {
templateArgs[1],
templateArgs[2],
pm = templateArgs['pm'],
dsv = templateArgs['dsv'],
hide = templateArgs['hide'],
quality = templateArgs['quality'],
}
}
end
-- =p.render{args={"Pufferfish","200"}}
function p.render(frame)
local args = frame.args
local cacheKey = KEY_PREFIX .. "|" .. args[1] .. "|" .. args[2] .. "|" .. (args['pm'] or "") .. "|" .. (args['dsv'] or "").. "|" .. (args['hide'] or "").. "|" .. (args['quality'] or "")
cache.delete(cacheKey)
if cache.get(cacheKey) then
local result = cache.get(cacheKey)
-- return result
end
local result = expandTemplate(args)
cache.set(cacheKey, result, EXP_TIME)
return result
end
return p