Module:Navigation header
Appearance
![]() | This module depends on the following other modules: |
![]() | This module uses TemplateStyles: |
Implements Template:Navigation header.
Functions
main
main(frame: table) -> string
Takes a frame object containing the template's arguments and generates a navigation header.
frame: A table containing the arguments passed to the module.
Returns: A string representing the generated HTML for the navigation header.
_main
_main(args: table) -> string
Takes an args object containing another module's arguments into this module and does the same as above.
local p = {}
function p.main(frame)
local parent = frame:getParent()
local pages = {}
local index = 1
while parent.args['page' .. index] or parent.args['content' .. index] do
local pageName = parent.args['page' .. index]
local content = parent.args['content' .. index]
local sectionName = parent.args['section' .. index]
local pageDiv = mw.html.create('div'):addClass('blocks-block')
if sectionName then
local editLink
if pageName then
editLink = mw.uri.makeFullUrl(pageName, {action = 'edit', section = tostring(index)})
elseif content then
editLink = mw.uri.makeFullUrl(mw.title.getCurrentTitle().prefixedText, {action = 'edit', section = tostring(index)})
end
local editButton = mw.html.create('span')
:addClass('mw-editsection')
:wikitext('[' .. editLink .. ' edit]')
pageDiv:wikitext('\n==' .. sectionName .. '== ' .. tostring(editButton))
end
if pageName then
local transcludedContent = frame:expandTemplate{title = pageName}
pageDiv:wikitext('\n' .. transcludedContent)
elseif content then
pageDiv:wikitext('\n' .. content)
end
table.insert(pages, pageDiv)
index = index + 1
end
if #pages == 0 then
return ''
end
local mainDiv = mw.html.create('div')
for _, pageDiv in ipairs(pages) do
mainDiv:node(pageDiv)
end
return tostring(mainDiv)
end
return p