Module:ScopeBox: Difference between revisions
From Amaranth Legacy, available at amaranth-legacy.community
More actions
Content deleted Content added
Tesinormed (talk | contribs) No edit summary |
Tesinormed (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local libraryUtil = require('libraryUtil') |
|||
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg |
|||
local p = {} |
local p = {} |
||
| Line 8: | Line 5: | ||
-- input validation |
-- input validation |
||
if not args['scope'] then error('"scope" argument is required') end |
if not args['scope'] then error('"scope" argument is required') end |
||
if not args['symbol'] and not (args['left_symbol'] and args['right_symbol']) then error('"symbol" argument is required') end |
|||
local |
local wrapper = mw.html.create('div') |
||
:addClass('template-ScopeBox') |
:addClass('template-ScopeBox') |
||
:addClass('template-ScopeBox--' .. args['scope']) |
:addClass('template-ScopeBox--' .. args['scope']) |
||
:tag('div') |
:tag('div') |
||
:addClass('template-ScopeBox-content') |
|||
:tag('div') |
|||
local left_symbol = wrapper:tag('div') |
|||
| ⚫ | |||
if args['left_symbol'] or args['symbol'] then |
|||
:done() |
|||
| ⚫ | |||
:tag('div') |
|||
end |
|||
| ⚫ | |||
:done() |
|||
wrapper:tag('div') |
|||
:wikitext('[[Scope:' .. args['scope'] .. '|' .. args['scope'] .. ']]') |
|||
:done() |
|||
:done() |
:done() |
||
local right_symbol = wrapper:tag('div') |
|||
if args['right_symbol'] or args['symbol'] then |
|||
| ⚫ | |||
end |
|||
return frame:extensionTag { name = 'templatestyles', args = { src = 'Module:ScopeBox/styles.css' } } |
return frame:extensionTag { name = 'templatestyles', args = { src = 'Module:ScopeBox/styles.css' } } |
||
.. frame:extensionTag { name = 'templatestyles', args = { src = 'Module:ScopeBox/styles-' .. args['scope'] .. '.css' } } |
.. frame:extensionTag { name = 'templatestyles', args = { src = 'Module:ScopeBox/styles-' .. args['scope'] .. '.css' } } |
||
.. tostring( |
.. tostring(wrapper) |
||
end |
end |
||
Revision as of 07:01, February 4, 2025
This module is used for Template:ScopeBox. See the template's page for more information.
local p = {}
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
-- input validation
if not args['scope'] then error('"scope" argument is required') end
local wrapper = mw.html.create('div')
:addClass('template-ScopeBox')
:addClass('template-ScopeBox--' .. args['scope'])
:tag('div')
:addClass('template-ScopeBox-content')
local left_symbol = wrapper:tag('div')
if args['left_symbol'] or args['symbol'] then
left_symbol:wikitext('[[File:' .. (args['left_symbol'] or args['symbol']) .. '|80px|link=|alt=]]')
end
wrapper:tag('div')
:wikitext('[[Scope:' .. args['scope'] .. '|' .. args['scope'] .. ']]')
:done()
local right_symbol = wrapper:tag('div')
if args['right_symbol'] or args['symbol'] then
right_symbol:wikitext('[[File:' .. (args['right_symbol'] or args['symbol']) .. '|80px|link=|alt=]]')
end
return frame:extensionTag { name = 'templatestyles', args = { src = 'Module:ScopeBox/styles.css' } }
.. frame:extensionTag { name = 'templatestyles', args = { src = 'Module:ScopeBox/styles-' .. args['scope'] .. '.css' } }
.. tostring(wrapper)
end
return p