Module:Module sandbox: Difference between revisions
Appearance
Content deleted Content added
Clear Tags: Blanking Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
require('Module:No globals') |
|||
local getArgs = require('Module:Arguments').getArgs |
|||
local p = {} |
|||
local infoboxImage = require('Module:InfoboxImage').InfoboxImage |
|||
local lc = require('Module:WikitextLC').selective |
|||
function p.main(frame) |
|||
local args = getArgs(frame) |
|||
return p._main(args) |
|||
end |
|||
function p._main(args) |
|||
-- Main module code goes here. |
|||
local variety = {'', '-hans', '-hant', '-cn', '-hk', '-mo', '-sg', '-tw'} |
|||
local varietyHans = {'-hans', '-cn', '-sg'} |
|||
local varietyHant = {'-hant', '-hk', '-mo', '-tw'} |
|||
local hansIndicator, hantIndicator = false, false |
|||
for i, v in ipairs(varietyHans) do |
|||
if args['image' .. v] then |
|||
hansIndicator = true |
|||
break |
|||
end |
|||
end |
|||
for i, v in ipairs(varietyHant) do |
|||
if args['image' .. v] then |
|||
hantIndicator = true |
|||
break |
|||
end |
|||
end |
|||
if hansIndicator and hansIndicator then |
|||
local content = {} |
|||
for i, v in ipairs(variety) do |
|||
local parameter = 'image' .. v |
|||
local value = args[patameter] |
|||
if value then |
|||
content[parameter] = infoboxImage{args = {image = value, sizedefault = 'frameless', upright = '1.15'}} |
|||
end |
|||
end |
|||
return lc(content) |
|||
end |
|||
return infoboxImage{args = {image = args.image, sizedefault = 'frameless', upright = '1.15'}} |
|||
end |
|||
return p |
Revision as of 10:50, 6 April 2025
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local p = {}
local infoboxImage = require('Module:InfoboxImage').InfoboxImage
local lc = require('Module:WikitextLC').selective
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
-- Main module code goes here.
local variety = {'', '-hans', '-hant', '-cn', '-hk', '-mo', '-sg', '-tw'}
local varietyHans = {'-hans', '-cn', '-sg'}
local varietyHant = {'-hant', '-hk', '-mo', '-tw'}
local hansIndicator, hantIndicator = false, false
for i, v in ipairs(varietyHans) do
if args['image' .. v] then
hansIndicator = true
break
end
end
for i, v in ipairs(varietyHant) do
if args['image' .. v] then
hantIndicator = true
break
end
end
if hansIndicator and hansIndicator then
local content = {}
for i, v in ipairs(variety) do
local parameter = 'image' .. v
local value = args[patameter]
if value then
content[parameter] = infoboxImage{args = {image = value, sizedefault = 'frameless', upright = '1.15'}}
end
end
return lc(content)
end
return infoboxImage{args = {image = args.image, sizedefault = 'frameless', upright = '1.15'}}
end
return p