Module:Navbar/sandbox: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
make .done work right
use mw.html
Line 2:
 
local getArgs
local HtmlBuilder = require('Module:HtmlBuilder')
 
local function trim(s)
Line 9 ⟶ 8:
 
local function htmlError(s)
local span = HtmlBuildermw.html.create('span')
 
span
.:addClass('error')
.:css('float', 'left')
.:css('white-space', 'nowrap')
.:wikitext('Error: ' .. s)
 
return tostring(span)
Line 72 ⟶ 71:
end
 
local div = HtmlBuildermw.html.create().:tag('div')
div
.:addClass('plainlinks')
.:addClass('hlist')
.:addClass('navbar')
.:cssText(args.style)
 
if args.mini then div.:addClass('mini') end
 
if not (args.mini or args.plain) then
div
.:tag('span')
.:css('word-spacing', 0)
.:cssText(args.fontstyle)
.:wikitext(args.text or 'This box:')
.:wikitext(' ')
end
 
if args.brackets then
div
.:tag('span')
.:css('margin-right', '-0.125em')
.:cssText(args.fontstyle)
.:wikitext('[')
.:newline();
end
 
local ul = div.:tag('ul');
 
ul
.:tag('li')
.:addClass('nv-view')
.:wikitext('[[' .. mainpage .. '|')
.:tag('span')
.:attr('title', 'View this template')
.:cssText(args.fontstyle or '')
.:wikitext(viewLink)
.:done()
.:wikitext(']]')
.:done()
.:tag('li')
.:addClass('nv-talk')
.:wikitext('[[' .. talkpage .. '|')
.:tag('span')
.:attr('title', 'Discuss this template')
.:cssText(args.fontstyle or '')
.:wikitext(talkLink)
.:done()
.:wikitext(']]');
 
if not args.noedit then
ul
.:tag('li')
.:addClass('nv-edit')
.:wikitext('[' .. editurl .. ' ')
.:tag('span')
.:attr('title', 'Edit this template')
.:cssText(args.fontstyle or '')
.:wikitext(editLink)
.:done()
.:wikitext(']');
end
 
if args.brackets then
div
.:tag('span')
.:css('margin-left', '-0.125em')
.:cssText( args.fontstyle or '')
.:wikitext(']')
.:newline();
end
if args.collapsible then
div
.:done()
.:tag('span')
.:css('font-size', '110%')
.:cssText(args.fontstyle or '')
.:wikitext(args[1])
end
 
return tostring(div.:allDone())
end