Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
You must create an account or log in to edit.

Module:ScopeBox: Difference between revisions

From Amaranth Legacy, available at amaranth-legacy.community
Content deleted Content added
Created page with "local libraryUtil = require('libraryUtil') local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg 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 output = mw.html.create('div') :addClass('template-ScopeBox') :addClass('template-ScopeBox--' .. args['scope']) :tag('div') :addClass('template-ScopeBox-content') :t..."
 
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
local libraryUtil = require('libraryUtil')
local yesno = require('Module:Yesno')
local checkTypeForNamedArg = libraryUtil.checkTypeForNamedArg


local p = {}
local p = {}
Line 7: Line 6:
local args = require('Module:Arguments').getArgs(frame)
local args = require('Module:Arguments').getArgs(frame)
-- input validation
-- input validation
if not args['scope'] then error('"scope" argument is required') end
if not args['identifier'] then error('"identifier" argument is required') end
if not args['link'] then error('"link" argument is required') end


local output = mw.html.create('div')
local wrapper = mw.html.create('div')
:addClass('template-ScopeBox')
:addClass('template-ScopeBox')
:addClass('template-ScopeBox--' .. args['scope'])
:addClass('template-ScopeBox--' .. args['identifier'])
:tag('div')
local content = mw.html.create('div')
:addClass('template-ScopeBox-content')
:addClass('template-ScopeBox-content')
:tag('div')

:done()
:tag('div')
local left_symbol = content:tag('div')
if args['left_symbol'] or args['symbol'] then
:done()
left_symbol:wikitext('[[File:' .. (args['left_symbol'] or args['symbol']) .. '|80px|link=|alt=]]')
:tag('div')
end
:done()

:done()
local link = content:tag('div')
if not yesno(args['link_not_scope_page'] or false) then
link:wikitext('[[Scope:' .. args['link'] .. '|' .. args['link'] .. ']]')
else
link:wikitext('[[' .. args['link'] .. '|' .. args['link'] .. ']]')
end

local right_symbol = content:tag('div')
if args['right_symbol'] or args['symbol'] then
right_symbol:wikitext('[[File:' .. (args['right_symbol'] or args['symbol']) .. '|80px|link=|alt=]]')
end

wrapper:node(content)


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 = 'rawcss', args = { src = 'Scope box', vars = 'Scope box/' .. args['identifier'] } }
.. tostring(output)
.. tostring(wrapper)
end
end



Latest revision as of 15:39, April 4, 2025

This module is used for Template:ScopeBox. See the template's page for more information.


local yesno = require('Module:Yesno')

local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame)
	-- input validation
	if not args['identifier'] then error('"identifier" argument is required') end
	if not args['link'] then error('"link" argument is required') end

	local wrapper = mw.html.create('div')
		:addClass('template-ScopeBox')
		:addClass('template-ScopeBox--' .. args['identifier'])
	
	local content = mw.html.create('div')
		:addClass('template-ScopeBox-content')

	local left_symbol = content:tag('div')
	if args['left_symbol'] or args['symbol'] then
		left_symbol:wikitext('[[File:' .. (args['left_symbol'] or args['symbol'])  .. '|80px|link=|alt=]]')
	end

	local link = content:tag('div')
	
	if not yesno(args['link_not_scope_page'] or false) then
		link:wikitext('[[Scope:' .. args['link'] .. '|' .. args['link'] .. ']]')
	else
		link:wikitext('[[' .. args['link'] .. '|' .. args['link'] .. ']]')
	end

	local right_symbol = content:tag('div')
	if args['right_symbol'] or args['symbol'] then
		right_symbol:wikitext('[[File:' .. (args['right_symbol'] or args['symbol'])  .. '|80px|link=|alt=]]')
	end

	wrapper:node(content)

	return frame:extensionTag { name = 'templatestyles', args = { src = 'Module:ScopeBox/styles.css' } }
		.. frame:extensionTag { name = 'rawcss', args = { src = 'Scope box', vars = 'Scope box/' .. args['identifier'] } }
		.. tostring(wrapper)
end

return p