Module:File link: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
add page, class and lang parameters
(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:
checkType('image:alt', 1, s, 'string', true)
data.theAlt = s
return self
end
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
end
Line 214 ⟶ 235:
end
-- Render named parameters.
-- Link
-- That includes link, alt, page, class, and lang.
if data.theLink then
do
ret[#ret + 1] = 'link=' .. data.theLink
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]
if data.theLinkvalue then
ret[#ret + 1] = parameter .. 'link=' .. data.theLinktostring(value)
end
end
end
 
-- Alt
if data.theAlt then
ret[#ret + 1] = 'alt=' .. data.theAlt
end
-- Caption
ret[#ret + 1] = data.theCaption
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu