Module:LuaPI

local p = {}

-- Some non-trivial, but non-extreme processing that runs in linear time function p.processArg(arg) if not arg then return "0" end local codepointSum = 0 for codepoint in mw.ustring.gcodepoint(arg) do		codepointSum = codepointSum + codepoint end return string.format("%s (%d)", arg, codepointSum) end

function p.createWithPreprocess(f) local frame = mw.getCurrentFrame local args = f	if f == frame then args = f.args end local infobox = mw.html.create("infobox") infobox :tag("title") :tag("default"):wikitext("Foo"):done :done

infobox :tag('data'):attr("source", "data1") :tag('label'):wikitext("Hello"):done :tag('format'):wikitext(p.processArg(args.data1)):done :tag('default'):wikitext("World"):done :done :tag('data'):attr("source", "data2") :tag('label'):wikitext("Hello 2"):done :tag('format'):wikitext(p.processArg(args.data2)):done :tag('default'):wikitext("World 2"):done :done :tag('data'):attr("source", "data3") :tag('label'):wikitext("Hello 3"):done :tag('format'):wikitext(p.processArg(args.data3)):done :tag('default'):wikitext("World 3"):done :done :tag('data'):attr("source", "data4") :tag('label'):wikitext("Hello 4"):done :tag('format'):wikitext(p.processArg(args.data4)):done :tag('default'):wikitext("World 4"):done :done :tag('data'):attr("source", "data5") :tag('label'):wikitext("Hello 5"):done :tag('format'):wikitext(p.processArg(args.data5)):done :tag('default'):wikitext("World 5"):done :done :tag('data'):attr("source", "data6") :tag('label'):wikitext("Hello 6"):done :tag('format'):wikitext(p.processArg(args.data6)):done :tag('default'):wikitext("World 6"):done :done :tag('data'):attr("source", "data7") :tag('label'):wikitext("Hello 7"):done :tag('format'):wikitext(p.processArg(args.data7)):done :tag('default'):wikitext("World 7"):done :done :tag('data'):attr("source", "data8") :tag('label'):wikitext("Hello 8"):done :tag('format'):wikitext(p.processArg(args.data8)):done :tag('default'):wikitext("World 8"):done :done :tag('data'):attr("source", "data9") :tag('label'):wikitext("Hello 9"):done :tag('format'):wikitext(p.processArg(args.data9)):done :tag('default'):wikitext("World 9"):done :done :tag('data'):attr("source", "data10") :tag('label'):wikitext("Hello 10"):done :tag('format'):wikitext(p.processArg(args.data10)):done :tag('default'):wikitext("World 10"):done :done :tag('data'):attr("source", "data11") :tag('label'):wikitext("Hello 11"):done :tag('format'):wikitext(p.processArg(args.data11)):done :tag('default'):wikitext("World 11"):done :done :tag('data'):attr("source", "data12") :tag('label'):wikitext("Hello 12"):done :tag('format'):wikitext(p.processArg(args.data12)):done :tag('default'):wikitext("World 12"):done :done :tag('data'):attr("source", "data13") :tag('label'):wikitext("Hello 13"):done :tag('format'):wikitext(p.processArg(args.data13)):done :tag('default'):wikitext("World 13"):done :done :tag('data'):attr("source", "data14") :tag('label'):wikitext("Hello 14"):done :tag('format'):wikitext(p.processArg(args.data14)):done :tag('default'):wikitext("World 14"):done :done :tag('data'):attr("source", "data15") :tag('label'):wikitext("Hello 15"):done :tag('format'):wikitext(p.processArg(args.data15)):done :tag('default'):wikitext("World 15"):done :done :tag('data'):attr("source", "data16") :tag('label'):wikitext("Hello 16"):done :tag('format'):wikitext(p.processArg(args.data16)):done :tag('default'):wikitext("World 16"):done :done :tag('data'):attr("source", "data17") :tag('label'):wikitext("Hello 17"):done :tag('format'):wikitext(p.processArg(args.data17)):done :tag('default'):wikitext("World 17"):done :done :tag('data'):attr("source", "data18") :tag('label'):wikitext("Hello 18"):done :tag('format'):wikitext(p.processArg(args.data18)):done :tag('default'):wikitext("World 18"):done :done :tag('data'):attr("source", "data19") :tag('label'):wikitext("Hello 19"):done :tag('format'):wikitext(p.processArg(args.data19)):done :tag('default'):wikitext("World 19"):done :done :tag('data'):attr("source", "data20") :tag('label'):wikitext("Hello 20"):done :tag('format'):wikitext(p.processArg(args.data20)):done :tag('default'):wikitext("World 20"):done :done return frame:preprocess(tostring(infobox)) end

function p.createWithExtensionTag(f) local frame = mw.getCurrentFrame local args = f	if f == frame then args = f.args end local infobox = frame:extensionTag('infobox', 		frame:extensionTag('title', frame:extensionTag('default', 'Foo') ) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 1') .. frame:extensionTag('format', p.processArg(args.data1)) .. frame:extensionTag('default', 'World 1') , { source = 'data1' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 2') .. frame:extensionTag('format', p.processArg(args.data2)) .. frame:extensionTag('default', 'World 2') , { source = 'data2' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 3') .. frame:extensionTag('format', p.processArg(args.data3)) .. frame:extensionTag('default', 'World 3') , { source = 'data3' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 4') .. frame:extensionTag('format', p.processArg(args.data4)) .. frame:extensionTag('default', 'World 4') , { source = 'data4' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 5') .. frame:extensionTag('format', p.processArg(args.data5)) .. frame:extensionTag('default', 'World 5') , { source = 'data5' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 6') .. frame:extensionTag('format', p.processArg(args.data6)) .. frame:extensionTag('default', 'World 6') , { source = 'data6' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 7') .. frame:extensionTag('format', p.processArg(args.data7)) .. frame:extensionTag('default', 'World 7') , { source = 'data7' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 8') .. frame:extensionTag('format', p.processArg(args.data8)) .. frame:extensionTag('default', 'World 8') , { source = 'data8' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 9') .. frame:extensionTag('format', p.processArg(args.data9)) .. frame:extensionTag('default', 'World 9') , { source = 'data9' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 10') .. frame:extensionTag('format', p.processArg(args.data10)) .. frame:extensionTag('default', 'World 10') , { source = 'data10' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 11') .. frame:extensionTag('format', p.processArg(args.data11)) .. frame:extensionTag('default', 'World 11') , { source = 'data11' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 12') .. frame:extensionTag('format', p.processArg(args.data12)) .. frame:extensionTag('default', 'World 12') , { source = 'data12' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 13') .. frame:extensionTag('format', p.processArg(args.data13)) .. frame:extensionTag('default', 'World 13') , { source = 'data13' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 14') .. frame:extensionTag('format', p.processArg(args.data14)) .. frame:extensionTag('default', 'World 14') , { source = 'data14' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 15') .. frame:extensionTag('format', p.processArg(args.data15)) .. frame:extensionTag('default', 'World 15') , { source = 'data15' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 16') .. frame:extensionTag('format', p.processArg(args.data16)) .. frame:extensionTag('default', 'World 16') , { source = 'data16' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 17') .. frame:extensionTag('format', p.processArg(args.data17)) .. frame:extensionTag('default', 'World 17') , { source = 'data17' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 18') .. frame:extensionTag('format', p.processArg(args.data18)) .. frame:extensionTag('default', 'World 18') , { source = 'data18' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 19') .. frame:extensionTag('format', p.processArg(args.data19)) .. frame:extensionTag('default', 'World 19') , { source = 'data19' }) ..		frame:extensionTag('data', frame:extensionTag('label', 'Hello 20') .. frame:extensionTag('format', p.processArg(args.data20)) .. frame:extensionTag('default', 'World 20') , { source = 'data20' })	) return infobox end

-- I'm not very good at names. ~ Someone who uses account "main" on computer "MainPC" function p.processArgUser(f) return p.processArg(f.args[1]) end

function p.processAllArgs(f) local frame = mw.getCurrentFrame local args = f	if f == frame then args = f:getParent.args end local result = { frame:callParserFunction("#vardefine", "luapi::data1", p.processArg(args.data1)), frame:callParserFunction("#vardefine", "luapi::data2", p.processArg(args.data2)), frame:callParserFunction("#vardefine", "luapi::data3", p.processArg(args.data3)), frame:callParserFunction("#vardefine", "luapi::data4", p.processArg(args.data4)), frame:callParserFunction("#vardefine", "luapi::data5", p.processArg(args.data5)), frame:callParserFunction("#vardefine", "luapi::data6", p.processArg(args.data6)), frame:callParserFunction("#vardefine", "luapi::data7", p.processArg(args.data7)), frame:callParserFunction("#vardefine", "luapi::data8", p.processArg(args.data8)), frame:callParserFunction("#vardefine", "luapi::data9", p.processArg(args.data9)), frame:callParserFunction("#vardefine", "luapi::data10", p.processArg(args.data10)), frame:callParserFunction("#vardefine", "luapi::data11", p.processArg(args.data11)), frame:callParserFunction("#vardefine", "luapi::data12", p.processArg(args.data12)), frame:callParserFunction("#vardefine", "luapi::data13", p.processArg(args.data13)), frame:callParserFunction("#vardefine", "luapi::data14", p.processArg(args.data14)), frame:callParserFunction("#vardefine", "luapi::data15", p.processArg(args.data15)), frame:callParserFunction("#vardefine", "luapi::data16", p.processArg(args.data16)), frame:callParserFunction("#vardefine", "luapi::data17", p.processArg(args.data17)), frame:callParserFunction("#vardefine", "luapi::data18", p.processArg(args.data18)), frame:callParserFunction("#vardefine", "luapi::data19", p.processArg(args.data19)), frame:callParserFunction("#vardefine", "luapi::data20", p.processArg(args.data20)) }	return table.concat(result) end

function p.processAllArgsLuaVars(f) local frame = mw.getCurrentFrame local args = f	if f == frame then args = f:getParent.args end local setVar = mw.ext.VariablesLua.vardefine local result = { setVar("luapi::data1", p.processArg(args.data1)), setVar("luapi::data2", p.processArg(args.data2)), setVar("luapi::data3", p.processArg(args.data3)), setVar("luapi::data4", p.processArg(args.data4)), setVar("luapi::data5", p.processArg(args.data5)), setVar("luapi::data6", p.processArg(args.data6)), setVar("luapi::data7", p.processArg(args.data7)), setVar("luapi::data8", p.processArg(args.data8)), setVar("luapi::data9", p.processArg(args.data9)), setVar("luapi::data10", p.processArg(args.data10)), setVar("luapi::data11", p.processArg(args.data11)), setVar("luapi::data12", p.processArg(args.data12)), setVar("luapi::data13", p.processArg(args.data13)), setVar("luapi::data14", p.processArg(args.data14)), setVar("luapi::data15", p.processArg(args.data15)), setVar("luapi::data16", p.processArg(args.data16)), setVar("luapi::data17", p.processArg(args.data17)), setVar("luapi::data18", p.processArg(args.data18)), setVar("luapi::data19", p.processArg(args.data19)), setVar("luapi::data20", p.processArg(args.data20)) }	return table.concat(result) end

return p