Module:Infobox: Difference between revisions
When a parameter is nil, make sure the function is called with it being set to nil (previously, all other parameters would be shifted left one)
m (Errant bracket) |
(When a parameter is nil, make sure the function is called with it being set to nil (previously, all other parameters would be shifted left one)) |
||
(10 intermediate revisions by 4 users not shown) | |||
Line 4:
-- <nowiki>
require('strict')
local editbutton = require('Module:Edit button')
local smwutils = require('Module:SMW Utils')
Line 58 ⟶ 59:
--]]
function Infobox.param(param_name)
local param = {
property = 'args_parsed',
param_name = param_name,
Line 71 ⟶ 72:
--]]
function Infobox.raw_param(param_name)
local param = {
property = 'args_raw',
param_name = param_name,
Line 84 ⟶ 85:
--]]
function Infobox.smw_param(param_name)
local param = {
property = 'args_smw',
param_name = param_name,
Line 171 ⟶ 172:
_cell:wikitext(content)
-- Add the switch data if multiple values exist
local data_attr_param = self:add_switch_data(v.content)
if data_attr_param then
_cell:attr('data-attr-param', data_attr_param)
Line 237 ⟶ 238:
--]]
function Infobox:parse_versions()
local function insert_version_name(version_name)
table.insert(self.version_names, version_name)
if smwutils.valid_subobject_name(version_name) == false then
Line 368 ⟶ 369:
local func_params = func.params
local func_fetched_params = {}
local i = 1
for _, func_param in ipairs(func_params) do
i = i + 1
end
return func_name(unpack(func_fetched_params))
Line 409 ⟶ 412:
:addClass('infobox-'..self.infobox_name)
for _, class in ipairs(self.classes) do
if type(class_name) == 'string' then
self.rtable:addClass('infobox-'..mw.ustring.gsub(class_name, '%s', '_'))
end
-- Create the switch datatable if multiple versions
Line 468 ⟶ 474:
local property = self.params[param_name].smw_property
if property then
local value = self:get_param(self.smw_param(param_name), version)
if value ~= nil then
subobject[property] = value
Line 549 ⟶ 555:
name = 'smw__' + name
end
local data_param = self.switch_datatable:tag('span'):attr('data-attr-param', name)
-- Add each version to the datatable
for version=1, self.versions do
local text = self:get_param(content, version)
if text == nil then
text = self.params[content.param_name].empty
Line 562 ⟶ 568:
end
▲ end
end▼
--[[
Line 587 ⟶ 580:
-- Create categories
local category_text = ''
if mw.title.getCurrentTitle():inNamespace(0) then
category_text = category_text..'[[Category:'..key..']]'
▲ end
end
local dump = ''
|