« Module:Fermentation » : différence entre les versions
Annulation des modifications 72900 de Kims (discussion) Balise : Annulation |
Annulation des modifications 72900 de Kims (discussion) |
||
Ligne 8 : | Ligne 8 : | ||
local data = { | local data = { | ||
["fermentable"] = { | ["fermentable"] = { }, | ||
["fermenté"] = {}, | |||
["fermenté"] = { | ["mature"] = { } | ||
["mature"] = { | |||
} | } | ||
Ligne 23 : | Ligne 20 : | ||
return mw.html.create( 'li' ) | return mw.html.create( 'li' ) | ||
:addClass( 'avt-interactions- | :addClass( 'avt-interactions-text' ) | ||
:tag( 'div' ) | :tag( 'div' ) | ||
:wikitext( note ) | :wikitext( note ) |
Version du 19 juillet 2021 à 17:29
La documentation pour ce module peut être créée à Module:Fermentation/doc
local p = {}
local LF = '\n'
--------------------------------
----- Référentiel -----
--------------------------------
local data = {
["fermentable"] = { },
["fermenté"] = {},
["mature"] = { }
}
--------------------------------
function buildRow(argValue, def)
local note = argValue or ''
if note ~= '' then note = LF .. note .. LF end
return mw.html.create( 'li' )
:addClass( 'avt-interactions-text' )
:tag( 'div' )
:wikitext( note )
:done()
:tag( 'li' )
:wikitext( '[[Fichier:Icon_range_inverse.png|x50px|center]]' )
:done()
end
function p._build(args)
local res = mw.html.create( 'ul' )
:addClass( 'avt-interactions' )
local isEmpty = true
for key, value in pairs(args) do
local def = data[key:lower()]
if def and value ~= '-' and value ~= 'vide' then
isEmpty = false
res:node(buildRow(value, def))
end
end
-- cas particulier l'inventaire du pnj est vide
if isEmpty then
res:node(buildRow(nil, data.vide))
end
res:allDone()
return res
end
function p.build(frame)
local args = {}
local argsParent = frame:getParent().args
for cle, val in pairs(argsParent) do
if val then
val = mw.text.trim(val)
if val ~= '' then
args[cle] = val
end
end
end
return p._build(args)
end
return p