require('strict')
local getArgs = require('Module:Arguments').getArgslocal mHatnote = require('Module:Hatnote')
local templatestyles = 'TemplateStyles sandbox/N8wilson/SeeFAQstyles.css'
local p =
local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame) return p[funcName](args) endend
function p.ternary(cond, ctrue, cfalse) if cond then return ctrue end return cfalseend
p.pinned = makeInvokeFunc('_pinned')function p._pinned(args) -- Generate FAQ for inclusion as the first discussion at the top of the page. local builder = mw.html.create
builder:tag('div') :addClass('faq-item') :tag('div') :addClass('faq-link-key') :wikitext(p.ternary(args['link-key'], .. args['link-key'], )) :done :tag('span') :addClass('faq-question') :wikitext('Q' .. (args.index or ) .. '. ' .. (args.q or )) :done :tag('span') :addClass('faq-answer') :wikitext(args.a or )
return builder -- Do not include
") in order to be properly processed by minerva, -- the mobile skin. If the h2 is included directly, minerva shows it but makes -- the content underneath it inaccessible on mobile interfaces. end
p.faqpage = makeInvokeFunc('_faqpage')function p._faqpage(args) -- Generate FAQ as it should render on the FAQ content page with anchors to questions local builder = mw.html.create
builder:tag('div') :addClass('faq-item faq-page') :tag('h3') :addClass('faq-question') :addClass('anchor') :attr('id', ('kFAQ-' .. (args['link-key'] or ))) :wikitext(args.q or nil) :done :wikitext(mHatnote._hatnote(tostring(args['link-key'] or ),)) :tag('div') :addClass('faq-short-answer') :wikitext(args['short-a'] or ) :done :tag('div') :addClass('faq-answer') :wikitext(args.a or ) :done
return builderend
p.default = makeInvokeFunc('_default')function p._default(args) -- Generate item as it should render outside of the FAQ page -- (assume ref to single question in discussion) local builder = mw.html.create
builder:tag('span') :addClass('faq-question') :wikitext(args.q or )
builder:tag('span') :addClass('faq-answer') :wikitext(args.a or )
return builderend
p.beginsection = makeInvokeFunc('_beginsection')function p._beginsection(args) return mw.html.create('section',) :attr('begin', (args.key or ))end
p.endsection = makeInvokeFunc('_endsection')function p._endsection(args) return mw.html.create('section',) :attr('end', (args.key or ))end
p.main = makeInvokeFunc('_main')function p._main(args) -- make a decision about which format to use based on params if 'FAQ'
'pinned' then return p._pinned(args) end return p._default(args)end
return p