Anonymous user
Module:File link: Difference between revisions
add page, class and lang parameters
Enwikipedia>Mr. Stradivarius (allow nil values as input to most of the functions, to make call-chaining with conditional variables easier) |
Enwikipedia>Mr. Stradivarius (add page, class and lang parameters) |
||
Line 163:
checkType('image:alt', 1, s, 'string', true)
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
end
Line 214 ⟶ 235:
end
-- Render named parameters.
-- 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]
end
end
end
▲ end
-- Caption
ret[#ret + 1] = data.theCaption
|