Module:Sandbox/BrandonXLF/4: Difference between revisions

Content deleted Content added
No edit summary
Fix errors
 
(17 intermediate revisions by the same user not shown)
Line 2:
local p = {}
 
local roadDataModule = require('Module:Road data/sandbox') -- REMOVE SANDBOX
function p.main(frame)
 
local wikitext = frame:preprocess(frame.args[1])
function p._shieldmain(args)
local itemsshields = {}
local outrouteCount = ''1
while args[routeCount * 2 - 1] do
-- Parse each row
local postroute = ':'{
for indent, item in wikitext:gmatch("(**) *([^\n]+)") do
country = args['country' .. routeCount] or args.country,
items[#items + 1] = {'*' .. indent, item}
state = args['state' .. routeCount] or args['province' .. routeCount] or args.state or args.province,
end
type = args[routeCount * 2 - 1],
 
route = args[routeCount * 2]
-- Bold sublist titles and add a blank list item before them
}
-- The blank item is used by CSS to make the list item block leel
for i, item in pairs(items) do
-- Added by {{Keep inline}}
local keepInline = item[2]:match('KEEP%-INLINE$') ~= nil
if keepInlinenot route.country then
local countryModule = mw.loadData('Module:Road data/countrymask')
item[2] = item[2]:gsub(' *KEEP%-INLINE$', '') .. '<span class="content-list-inline"></span>'
route.country = countryModule[route.state] or 'UNK'
end
if not keepInline and i < #items and #items[i + 1][1] > #item[1] then
-- local post = inlineNext and '&#58;' or ''
local post = '&#58;'
item[2] = '\n' .. item[1] .. "'''''" .. item[2] .. post .. "'''''"
end
 
local shield = roadDataModule.shield(route, 'main', 'infobox', true)
table.insert(shields, shield)
 
routeCount = routeCount + 1
end
 
return table.concat(shields, '&thinsp;')
local out = ''
end
 
for _, item in pairs(items) do
function p.mainshieldmain(frame)
out = out .. item[1] .. item[2] .. '\n'
local args = require('Module:Arguments').getArgs(frame)
end
return p._shieldmain(args)
return '<div class="content-list">\n' .. out .. '</div>' .. frame:extensionTag{
name = 'templatestyles', args = { src = 'User:BrandonXLF/styles2.css' }
}
end