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

Aucun résumé des modifications
m fix typo
 
(27 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 MessageBox= {}
local p = {}


function MessageBox:export()
function MessageBox:export()
     local root = mw.html.create()
     local root = mw.html.create('div')


     local article = root:tag('article')
    root:wikitext(
     article:wikitext('[[' .. self.image .. ']]')
        mw.getCurrentFrame():extensionTag( 'templatestyles', '', { src = 'Module:Message_box/style.css' } )
     article:tag('h4'):wikitext(self.title)
    )
     article:tag('p'):wikitext(self.content)
    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
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


     self:export()
function p.main(frame)
     local box = MessageBox:new(frame.args[1], frame.args[2], frame.args[3], frame.args[4])
    return box:export()
end
end


return MessageBox
return p