Module:Birdcraft plate
Appearance
This module depends on the following other modules: |
Logic for {{birdcraft plate}}.
require('strict')
local p = {} --p stands for package
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local function missing_value(value)
return '<span class="__missing-value">(missing ' .. value .. ')</span>'
end
function p._birdcraft_plate(args)
local plate_type = args['type']
if plate_type ~= 'tall' and plate_type ~= 'double' then
plate_type = 'single'
end
local plate = args.plate or missing_value('plate number')
local missing_image_image = 'No image 3x4.svg'
local img1 = args.img or args.img1 or args[3] or missing_image_image
local name1 = args.name or args.name1 or missing_value('name')
local length1 = args.length or args.length1 or missing_value('size')
local plate_content = {}
if plate_type == 'single' then
local gendered = yesno(args.gendered or 'no')
local subcaption = args.subcaption
local customlength = args.customlength or 'Length, ' .. length1 .. ' inches.'
local gendered_text = ''
local subcaption_text = ''
if gendered then
gendered_text = '<span class="__male">1. Male</span><span class="__female">2. Female</span>'
end
if subcaption then
subcaption_text = '<span class="__subcap">' .. subcaption .. '</span>'
end
plate_content = {
'[[File:' .. img1 .. '|frameless|480px|class=__image|link=]]',
'<span class="__name">' .. name1 .. '.</span>',
gendered_text .. subcaption_text,
'<span class="__length">' .. customlength .. '</span>'
}
else
local img2 = args.img2 or args[6] or missing_image_image
local name2 = args.name2 or missing_value('name')
local length2 = args.length2 or missing_value('size')
plate_content = {
'[[File:' .. img1 .. '|frameless|480px|class=__image1|link=]]',
'<span class="__name __name1">1. ' .. name1 .. '.</span>',
'<span class="__length __length1">Length, ' .. length1 .. ' inches.</span>',
'[[File:' .. img2 .. '|frameless|480px|class=__image2|link=]]',
'<span class="__name __name2">2. ' .. name2 .. '.</span>',
'<span class="__length __length2">Length, ' .. length2 .. ' inches.</span>'
}
end
return '<div class="__' .. plate_type .. '">\n<span class="__plateno">Plate ' .. plate .. '.</span>\n' .. table.concat(plate_content, '\n') .. '\n</div>'
end
function p.birdcraft_plate(frame)
return p._birdcraft_plate(getArgs(frame, {trim = true, removeBlanks = false}))
end
return p