Jump to content

Module:Documentation: Difference between revisions

make startBox, content and endBox accessible from #invoke
m>Mr. Stradivarius
(more efficient code for the subpages link)
m>Mr. Stradivarius
(make startBox, content and endBox accessible from #invoke)
Line 41: Line 41:


----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Main functions
-- Argument processing
----------------------------------------------------------------------------
----------------------------------------------------------------------------


function p.main(frame)
local function makeInvokeFunc(funcName)
local args = getArgs(frame, {
return function (frame)
valueFunc = function (key, value)
local args = getArgs(frame, {
if type(value) == 'string' then
valueFunc = function (key, value)
value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
if type(value) == 'string' then
if key == 'heading' or value ~= '' then
value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
if key == 'heading' or value ~= '' then
return value
else
return nil
end
else
return value
return value
else
return nil
end
end
else
return value
end
end
end
})
})
return p[funcName](args)
return p._main(args)
end
end
end
----------------------------------------------------------------------------
-- Main functions
----------------------------------------------------------------------------
p.main = makeInvokeFunc('_main')


function p._main(args)
function p._main(args)
Line 72: Line 80:
.attr('id', 'template-documentation')
.attr('id', 'template-documentation')
.addClass('template-documentation iezoomfix')
.addClass('template-documentation iezoomfix')
.wikitext(p.startBox(args))
.wikitext(p._startBox(args))
.wikitext(p.content(args))
.wikitext(p._content(args))
.tag('div')
.tag('div')
.css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
.css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
.done()
.done()
.done()
.done()
.wikitext(p.endBox(args))
.wikitext(p._endBox(args))
.wikitext(p.addTrackingCategories())
.wikitext(p.addTrackingCategories())
return tostring(root)
return tostring(root)
Line 120: Line 128:
end
end


function p.startBox(args)
p.startBox = makeInvokeFunc('_startBox')
 
function p._startBox(args)
-- Arg processing from {{documentation}}.
-- Arg processing from {{documentation}}.
local preload = args.preload -- Allow custom preloads.
local preload = args.preload -- Allow custom preloads.
Line 214: Line 224:
end
end


function p.content(args)
p.content = makeInvokeFunc('_content')
 
function p._content(args)
local content = args.content
local content = args.content
if not content then
if not content then
Line 234: Line 246:
end
end


function p.endBox(args)
p.endBox = makeInvokeFunc('_endBox')
 
function p._endBox(args)
-- Argument processing in {{documentation}}.
-- Argument processing in {{documentation}}.
local preload = args.preload -- Allow custom preloads.
local preload = args.preload -- Allow custom preloads.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.