模块:Path
来自星砂岛百科
更多操作
此模块的文档可以在模块:Path/doc创建
local p = {}
function p.main(frame)
local args = frame:getParent().args
local currentTitle = mw.title.getCurrentTitle().fullText
-- Create the outer container
local root = mw.html.create('div'):addClass('ss-path')
-- Create the inner content container and keep a reference to it
local content = root:tag('div'):addClass('ss-path-content')
local function addSep(node)
node:tag('span')
:addClass('ss-path-sep')
:wikitext('/')
end
-- 1. Add Main Page
content:wikitext('[[星砂岛百科|首页]]')
-- 2. Loop through numeric arguments
local i = 1
while args[i] do
local page = mw.text.trim(args[i])
if page ~= "" then
addSep(content)
content:wikitext('[[:' .. page .. ']]')
end
i = i + 1
end
-- 3. Add Current Page
addSep(content)
content:tag('span')
:addClass('ss-path-current')
:wikitext(currentTitle)
return tostring(root)
end
return p