Module:Infobox

De Lagny-sur-Marne Wiki
Version datée du 16 mars 2013 à 11:19 par 0x010D (discussion | contributions) (Nouvelle page : local Infobox = {} function Infobox:new( args ) --Object initialisation local object = { text = "", title = mw.title.getCurrentTitle() } setmetata...)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche

local Infobox = {}

function Infobox:new( args )

   --Object initialisation
   local object = {
       text = "",
       title = mw.title.getCurrentTitle()
   }
   setmetatable(object, {
       __index = Infobox,
       __tostring = function( self ) return self:tostring() end
   })
   --Open main div

local str = '

'
   return object

end

function Infobox:addTitle( args )

local str = '

' if args.text then str = str .. args.text else str = str .. self.title.text end self.text = self.text .. str .. '

'

end

function Infobox:tostring()

return self.text .. '

'

end

--Create a style property value from an array CSS property = CSS value function formatStyle( args )

   local elems = {}
   for args = key, val do
       elems.add( key .. ':' .. val )
   end
   return table.concat( elems, '; ' )

end

local p = {} function p.new( args )

   return Infobox:new( args )

end function p.test()

   local a = Infobox:new( {} )
   a:addTitle( {} )
   return a

end return p