Module:File link: Difference between revisions
From Roses, Tulips, & Liberty
Content added Content deleted
(allow nil values as input to most of the functions, to make call-chaining with conditional variables easier) |
(add page, class and lang parameters) |
||
Line 163: | Line 163: | ||
checkType('image:alt', 1, s, 'string', true) |
checkType('image:alt', 1, s, 'string', true) |
||
data.theAlt = s |
data.theAlt = s |
||
return self |
|||
⚫ | |||
function data:page(num) |
|||
checkSelf(self, 'image:page') |
|||
checkType('image:page', 1, num, 'number', true) |
|||
data.thePage = s |
|||
return self |
|||
end |
|||
function data:class(s) |
|||
checkSelf(self, 'image:class') |
|||
checkType('image:class', 1, s, 'string', true) |
|||
data.theClass = s |
|||
return self |
|||
end |
|||
function data:lang(s) |
|||
checkSelf(self, 'image:lang') |
|||
checkType('image:lang', 1, s, 'string', true) |
|||
data.theLang = s |
|||
return self |
return self |
||
end |
end |
||
Line 214: | Line 235: | ||
end |
end |
||
-- Render named parameters. |
|||
-- Link |
|||
-- That includes link, alt, page, class, and lang. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
local namedParameters = {'link', 'alt', 'page', 'class', 'lang'} |
|||
for i, parameter in ipairs(namedParameters) do |
|||
local dataField = 'the' .. parameter:sub(1, 1):upper() .. parameter:sub(2, -1) |
|||
local value = data[dataField] |
|||
⚫ | |||
⚫ | |||
end |
|||
end |
|||
end |
end |
||
⚫ | |||
-- Alt |
|||
if data.theAlt then |
|||
ret[#ret + 1] = 'alt=' .. data.theAlt |
|||
⚫ | |||
-- Caption |
-- Caption |
||
ret[#ret + 1] = data.theCaption |
ret[#ret + 1] = data.theCaption |