Template:Helpbox and Module:If empty: Difference between pages

From Frontierpedia, the Microsoft Agent encyclopedia
(Difference between pages)
m (2 revisions imported)
 
frontierpediav5>WikiSysop
(Created page with "local p = {} function p.main(frame) local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:If empty', removeBlanks = false}) -- For backwards compat...")
 
Line 1: Line 1:
<includeonly>{{Sidebar
local p = {}
| name = {{#if:{{{templatename|}}} |{{{templatename}}} |{{{name|{{PAGENAME}}}}} }}
| templatestyles = Template:Helpbox/styles.css
| child templatestyles = {{{child templatestyles|}}}
| float = {{{float|}}}
| class = help-box noprint {{{class|{{{bodyclass|}}}}}}
| style = {{{1|}}}


| titlestyle = {{{titlestyle|}}}
function p.main(frame)
| title = {{{title|{{{name|}}}}}}
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:If empty', removeBlanks = false})
| headingstyle = {{{headingstyle|}}}


| heading1  = {{{group1|}}}
-- For backwards compatibility reasons, the first 8 parameters can be unset instead of being blank,
| content1  = {{{list1|}}}
-- even though there's really no legitimate use case for this. At some point, this will be removed.
| heading2  = {{{group2|}}}
local lowestNil = math.huge
| content2  = {{{list2|}}}
for i = 8,1,-1 do
| heading3  = {{{group3|}}}
if args[i] == nil then
| content3  = {{{list3|}}}
args[i] = ''
| heading4  = {{{group4|}}}
lowestNil = i
| content4  = {{{list4|}}}
end
| heading5  = {{{group5|}}}
end
| content5  = {{{list5|}}}
| heading6  = {{{group6|}}}
| content6  = {{{list6|}}}
| heading7  = {{{group7|}}}
| content7  = {{{list7|}}}
| heading8  = {{{group8|}}}
| content8  = {{{list8|}}}
| heading9  = {{{group9|}}}
| content9  = {{{list9|}}}
| heading10 = {{{group10|}}}
| content10 = {{{list10|}}}
| heading11 = {{{group11|}}}
| content11 = {{{list11|}}}
| heading12 = {{{group12|}}}
| content12 = {{{list12|}}}
| heading13 = {{{group13|}}}
| content13 = {{{list13|}}}
| heading14 = {{{group14|}}}
| content14 = {{{list14|}}}
| heading15 = {{{group15|}}}
| content15 = {{{list15|}}}
| heading16 = {{{group16|}}}
| content16 = {{{list16|}}}
| heading17 = {{{group17|}}}
| content17 = {{{list17|}}}
| heading18 = {{{group18|}}}
| content18 = {{{list18|}}}
| heading19 = {{{group19|}}}
| content19 = {{{list19|}}}
| heading20 = {{{group20|}}}
| content20 = {{{list20|}}}


| navbar = {{#if:{{{templatename|}}} |
for k,v in ipairs(args) do
    | {{#if:{{{title|}}} |{{#if:{{{name|}}} | |none}}
if v ~= '' then
        | none
if lowestNil < k then
        }}
-- If any uses of this template depend on the behavior above, add them to a tracking category.
    }}
-- This is a rather fragile, convoluted, hacky way to do it, but it ensures that this module's output won't be modified
}}</includeonly><noinclude>
-- by it.
{{Documentation}}
frame:extensionTag('ref', '[[Category:Instances of Template:If_empty missing arguments]]', {group = 'TrackingCategory'})
</noinclude>
frame:extensionTag('references', '', {group = 'TrackingCategory'})
end
return v
end
end
end
 
return p

Revision as of 12:39, 15 June 2021

Documentation for this module may be created at Module:If empty/doc

local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:If empty', removeBlanks = false})

	-- For backwards compatibility reasons, the first 8 parameters can be unset instead of being blank,
	-- even though there's really no legitimate use case for this. At some point, this will be removed.
	local lowestNil = math.huge
	for i = 8,1,-1 do
		if args[i] == nil then
			args[i] = ''
			lowestNil = i
		end
	end

	for k,v in ipairs(args) do
		if v ~= '' then
			if lowestNil < k then
				-- If any uses of this template depend on the behavior above, add them to a tracking category.
				-- This is a rather fragile, convoluted, hacky way to do it, but it ensures that this module's output won't be modified
				-- by it.
				frame:extensionTag('ref', '[[Category:Instances of Template:If_empty missing arguments]]', {group = 'TrackingCategory'})
				frame:extensionTag('references', '', {group = 'TrackingCategory'})
			end
			return v
		end
	end
end

return p