“模块:TWRSideNavBox”的版本间的差异
跳到导航
跳到搜索
(创建页面,内容为“local p = {} itemString = "|-\n|[[File:{{{1}}}|50px|link={{FULLPAGENAME}}#{{{2}}}]]\n" function p.assemblyFixedNavBox( frame ) local returnString = "" for…”) |
|||
| 第5行: | 第5行: | ||
function p.assemblyFixedNavBox( frame ) | function p.assemblyFixedNavBox( frame ) | ||
local returnString = "" | local returnString = "" | ||
for k, v in pairs(frame) do | itemString = itemString:gsub("{{FULLPAGENAME}}", frame.args["pagename"]) | ||
for k, v in pairs(frame.args) do | |||
splitPoint = v:find("::") | splitPoint = v:find("::") | ||
-- Format of each element: "<File Name>::<Anchor>" | -- Format of each element: "<File Name>::<Anchor>" | ||
-- with no spaces | -- with no spaces in both sides of the backslash | ||
if splitPoint ~= nil and splitPoint > 1 then | if splitPoint ~= nil and splitPoint > 1 then | ||
name1 = v:sub(1, splitPoint - 1) | name1 = v:sub(1, splitPoint - 1) | ||
2022年1月2日 (日) 18:16的版本
local p = {}
itemString = "|-\n|[[File:{{{1}}}|50px|link={{FULLPAGENAME}}#{{{2}}}]]\n"
function p.assemblyFixedNavBox( frame )
local returnString = ""
itemString = itemString:gsub("{{FULLPAGENAME}}", frame.args["pagename"])
for k, v in pairs(frame.args) do
splitPoint = v:find("::")
-- Format of each element: "<File Name>::<Anchor>"
-- with no spaces in both sides of the backslash
if splitPoint ~= nil and splitPoint > 1 then
name1 = v:sub(1, splitPoint - 1)
name2 = v:sub(splitPoint + 2)
if name1:find("%.%w+$") ~= nil then
segment = itemString:gsub("{{{1}}}", name1)
else
-- If no file extension is found, assumes PNG by default
segment = itemString:gsub("{{{1}}}", name1 .. ".png")
end
segment = segment:gsub("{{{2}}}", name2)
returnString = returnString .. segment
end
end
return "{|\n" .. returnString .. "|}"
end
return p