Module:Scope hatnote: 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 Tag: Reverted |
||
| Line 1: | Line 1: | ||
local arguments = require('Module:Arguments') |
|||
local yesno = require('Module:Yesno') |
local yesno = require('Module:Yesno') |
||
| Line 4: | Line 5: | ||
function p.main(frame) |
function p.main(frame) |
||
local args = |
local args = arguments.getArgs(frame) |
||
local parentArgs = |
local parentArgs = arguments.getArgs(frame:getParent()) |
||
-- 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 |
||
Revision as of 17:30, February 20, 2025
General template for scope hatnote templates
Parameters
for- Used in the description of the TemplateData
rawcss_ref- RawCSS application reference to use
categories- Categories to use (like
Category:Scope: Imagindarium's Creation) use_remove_parentheses- If Module:Remove parentheses should be used
use_hatnote_links- If Template:Hatnote links should be used
local arguments = require('Module:Arguments')
local yesno = require('Module:Yesno')
local p = {}
function p.main(frame)
local args = arguments.getArgs(frame)
local parentArgs = arguments.getArgs(frame:getParent())
-- input validation
if not args['scope'] then error('"scope" argument is required') end
if not args['rawcss_ref'] then error('"rawcss_ref" argument is required') end
-- remove_parentheses is coerced into a boolean
local result = ''
-- remove parentheses in the page title
if yesno(args['remove_parentheses'] or true) then
result = result .. require('Module:Remove parentheses').main(frame)
end
-- apply the scope styling
if yesno(parentArgs['use_scope_styling'] or true) then
result = result .. frame:extensionTag('rawcss', '', {
ref = args['rawcss_ref']
})
end
-- hatnote
result = result .. frame:expandTemplate{title = 'Hatnote', args = args}
-- category
if yesno(parentArgs['add_category'] or true) then
result = result .. '\n[[Category:Scope: ' .. args['scope'] .. ']]'
end
-- TemplateData
result = result .. frame:getParent():preprocess('<noinclude>' ..
frame:extensionTag('templatedata',
[[{
"params": {
"add_category": {
"label": "Add category",
"description": "If the scope category should be added to the page",
"type": "boolean",
"default": "true"
},
"use_scope_styling": {
"label": "Use scope styling",
"description": "If the scope's styling should be used",
"type": "boolean",
"default": "true"
}
},
"description": "Scope hatnote for ]] .. args['scope'] .. [[",
"format": "inline",
"paramOrder": [
"add_category",
"use_scope_styling"
]
}]],
{}) .. '</noinclude>')
return result
end
return p