Module:Infobox: Difference between revisions
no edit summary
OtherXAdmin (talk | contribs) No edit summary Tag: Reverted |
OtherXAdmin (talk | contribs) No edit summary Tag: Reverted |
||
Line 14: | Line 14: | ||
end | end | ||
-- Initialize a new Infobox | |||
function Infobox.new(args) | function Infobox.new(args) | ||
local self = setmetatable({}, Infobox) | local self = setmetatable({}, Infobox) | ||
self.args = args | self.args = args | ||
-- Initialize | self.rows = {} -- Initialize the rows table | ||
return self | return self | ||
end | end | ||
-- | -- Define parameters for the infobox | ||
function Infobox.defineParams(self, params) | function Infobox.defineParams(self, params) | ||
self.params = params | self.params = params | ||
end | end | ||
-- | -- Add a row to the infobox | ||
function Infobox.addRow(self, row) | function Infobox.addRow(self, row) | ||
table.insert(self.rows, row) | table.insert(self.rows, row) | ||
end | end | ||
-- | -- Clean up parameters | ||
function Infobox.cleanParams(self) | function Infobox.cleanParams(self) | ||
if self.params then | if self.params then | ||
Line 46: | Line 43: | ||
end | end | ||
-- | -- Clean individual parameters (you can customize this if needed) | ||
function Infobox.cleanParam(self, param) | function Infobox.cleanParam(self, param) | ||
return param | return param | ||
end | end | ||
-- Generate the infobox based on the added rows | |||
-- | function Infobox.create(self) | ||
local output = {} -- Initialize the output table | |||
-- | -- You can customize the infobox structure here | ||
-- | table.insert(output, "{{Infobox start}}") | ||
for _, row in ipairs(self.rows) do | |||
table.insert(output, row) | |||
end | end | ||
table.insert(output, "{{Infobox end}}") | |||
end | |||
return table.concat(output, "\n") | |||
return | |||
end | end | ||
return Infobox | return Infobox |