Module:Infobox: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Reverted
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 other properties as needed
     self.rows = {} -- Initialize the rows table
     return self
     return self
end
end


-- defineParams method to set the parameters
-- Define parameters for the infobox
function Infobox.defineParams(self, params)
function Infobox.defineParams(self, params)
     self.params = params
     self.params = params
end
end


-- addRow method to add rows to the infobox
-- Add a row to the infobox
function Infobox.addRow(self, row)
function Infobox.addRow(self, row)
    if not self.rows then
        self.rows = {}
    end
     table.insert(self.rows, row)
     table.insert(self.rows, row)
end
end


-- cleanParams method to clean up the parameters
-- 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


-- cleanParam method to clean individual parameters
-- Clean individual parameters (you can customize this if needed)
function Infobox.cleanParam(self, param)
function Infobox.cleanParam(self, param)
    -- You can add custom cleaning logic for each parameter here
    -- For example, trimming whitespace, formatting dates, etc.
     return param
     return param
end
end


 
-- Generate the infobox based on the added rows
-- Standardised "release" function
function Infobox.create(self)
-- Standardised "release" function for dates
     local output = {} -- Initialize the output table
function releaseUpdate(release, update)
   
     -- Assuming release dates are entered in a valid format, return as is
     -- You can customize the infobox structure here
     -- Add any additional formatting or checks if needed
     table.insert(output, "{{Infobox start}}")
     return release
     for _, row in ipairs(self.rows) do
end
         table.insert(output, row)
 
-- Standardised "image" function for .png images
function image(img)
     -- Check if the image name ends with '.png', if not, add it
    if img and not img:match('%.png$') then
         img = img .. '.png'
     end
     end
     return img
     table.insert(output, "{{Infobox end}}")
end
      
 
     return table.concat(output, "\n")
-- Standardised "numbers" function for numeric values
function numbers(num)
     -- Convert to number if possible, else return nil or default value
     return tonumber(num)
end
end


return Infobox
return Infobox

Navigation menu