Module: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 '(missing ' .. value .. ') ' 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 = '1. Male 2. Female ' end if subcaption then subcaption_text = '' .. subcaption .. ' '		end plate_content = { '',			'' .. name1 .. '. ',			gendered_text .. subcaption_text, '' .. customlength .. ' '		}	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 = { '',			'1. ' .. name1 .. '. ',			'Length, ' .. length1 .. ' inches. ',			'',			'2. ' .. name2 .. '. ',			'Length, ' .. length2 .. ' inches. '		}	end return '\nPlate ' .. plate .. '. \n' .. table.concat(plate_content, '\n') .. '\n ' end

function p.birdcraft_plate(frame) return p._birdcraft_plate(getArgs(frame, {trim = true, removeBlanks = false})) end

return p