« Module:Message box » : différence entre les versions

Page créée avec « -- This is a meta-module for producing message box templates, inspired from mediawiki -- Define class function MessageBox:new (title, image, content) self.__index = self self.title = title self.image = image self.content = content end function MessageBox:export() local root = mw.html.create() local article = root:tag('article') article:wikitext('' .. self.image .. '') article:tag('h4'):wikitext(self.title) article:tag('p... »
 
m fix typo
 
(30 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
-- This is a meta-module for producing message box templates, inspired from mediawiki
-- This is a meta-module for producing message box templates, inspired from mediawiki
local MessageBox= {}
local p = {}
function MessageBox:export()
    local root = mw.html.create('div')
    root:wikitext(
        mw.getCurrentFrame():extensionTag( 'templatestyles', '', { src = 'Module:Message_box/style.css' } )
    )
    root:addClass('box')
    if self.class ~= nil then
        root:addClass(self.class)
    end
    local left = root:tag('div'):addClass('left')
    local right = root:tag('div'):addClass('right')
    if self.image ~= nil then
        left:wikitext('[[File:' .. self.image .. ']]')
    end
    left:tag('h4'):wikitext(self.title)
    right:tag('p'):wikitext(self.content)
    return tostring(root)
end


-- Define class
-- Define class
function MessageBox:new (title, image, content)
function MessageBox:new (title, content, image, class)
     self.__index = self
     self.__index = self
     self.title = title
     self.title = title
    self.content = content
     self.image = image
     self.image = image
     self.content = content
     self.class = class
 
    return self
end
end


function MessageBox:export()
function p.main(frame)
    local root = mw.html.create()
     local box = MessageBox:new(frame.args[1], frame.args[2], frame.args[3], frame.args[4])
 
     return box:export()
     local article = root:tag('article')
    article:wikitext('[[' .. self.image .. ']]')
     article:tag('h4'):wikitext(self.title)
    article:tag('p'):wikitext(self.content)
end
end


return MessageBox
return p