Module:Infobox: Difference between revisions
Jump to navigation
Jump to search
no edit summary
OtherXAdmin (talk | contribs) (Replaced content with "-- Module:Infobox - streamlined version without SMW dependencies -- <nowiki> local Infobox = {} Infobox.__index = Infobox Infobox.__tostring = Infobox.tostring -- Edit button for unknown params local editbutton = require('Module:Edit button') local edit = editbutton("'''?''' (edit)") -- Standardised "has content" function function hasContent(arg, default) return string.match(arg or '','%S') and arg or default end -- Create a standardised release function, since...") Tags: Replaced Reverted |
OtherXAdmin (talk | contribs) No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
-- Module:Infobox | -- Module:Infobox | ||
local Infobox = {} | local Infobox = {} | ||
Infobox.__index = Infobox | Infobox.__index = Infobox | ||
Line 12: | Line 11: | ||
-- Standardised "has content" function | -- Standardised "has content" function | ||
function hasContent(arg, default) | function hasContent(arg, default) | ||
return string.match(arg or '','%S') and arg or default | |||
end | end | ||
-- | -- Standardised "release" function | ||
-- Standardised "release" function for dates | |||
function releaseUpdate(release, update) | function releaseUpdate(release, update) | ||
-- Assuming release dates are entered in a valid format, return as is | |||
-- Add any additional formatting or checks if needed | |||
return release | |||
end | end | ||
-- Standardised image function | -- Standardised "image" function for .png images | ||
function image(img) | 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 | |||
return img | |||
end | end | ||
-- Standardised numbers | -- Standardised "numbers" function for numeric values | ||
function numbers(num) | function numbers(num) | ||
-- Convert to number if possible, else return nil or default value | |||
return tonumber(num) | |||
end | end | ||
return Infobox | return Infobox | ||