Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
fix names
Jackmcbarn (talk | contribs)
test bug in param order/parsing
Line 1:
local p = {}
 
function p.mainexpected(frame)
local retval = ''
return 'Hello world'
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:preprocess('{{#switch:' .. v .. '|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}') .. '\n\n'
end
return retval
end
 
function p.fnOnlyequalsInValue(frame)
local retval = ''
return mw.getCurrentFrame():callParserFunction('#invoke',{'Sandbox/Jackmcbarn', 'main'})
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:callParserFunction('#switch', {v, 'red', 'orange=1', 'yellow', 'green=2', 'blue', 'indigo=3', 'violet=4', '5'}) .. '\n\n'
end
return retval
end
 
function p.oneArgassociativeArray(frame)
local retval = ''
return mw.getCurrentFrame():callParserFunction('#invoke',{'Sandbox/Jackmcbarn', 'main', 'baz'})
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:callParserFunction('#switch', {v, 'red', orange='1', 'yellow', green='2', 'blue', indigo='3', violet='4', '5'}) .. '\n\n'
end
return retval
end
 
function p.twoArgsmain(frame)
return p.expected(frame) .. '\n\n' .. p.equalsInValue(frame) .. '\n\n' .. p.associativeArray(frame)
return mw.getCurrentFrame():callParserFunction('#invoke',{'Sandbox/Jackmcbarn', 'main', 'baz', 'qux'})
end