Module:Fermentation

La documentation pour ce module peut être créée à Module:Fermentation/doc

local p = {}

local LF = '\n'

--------------------------------
-----     Référentiel      ----- 
--------------------------------
-- à supprimer lorsque le module Icone sera OK
local icone = {
	['range'] = 'Icon_range_inverse',
}


local data = {
	["fermentable"] = {
		titre  = "Premier stade du brassage."
	},
	["fermenté"] = {
		titre  = "Second stade du brassage."
	},
	["mature"] = {
		titre  = "Troisième stade du brassage."
	}
}

--------------------------------

function buildRow(argValue, def)
	local note = argValue or ''
	if note ~= '' then note = LF .. note .. LF end

	return  mw.html.create( 'div' )
		:addClass( 'artisanat-colonne' )
		:tag( 'div' )
			:addClass( 'artisanat-colonne-titre' )
			:wikitext( def.titre )
			:done()
		:tag( 'div' )
			:addClass( 'artisanat-colonne-titre' )
			:wikitext( note )
			:done()
			:tag( 'div' )
			:wikitext( '[[Fichier:Icon_range_inverse.png|x25px|center]]' )
		:done()
	end

function p._build(args)
	local res = mw.html.create('ul')
		:addClass('avt-interactions')
		
	res
		:node(creerListeSimple(args, data.materiau, 'Matériaux'))
		:node(creerSeparateur('range', 'nécessite'))
		:node(creerListePrerequis(args))
		:node(creerSeparateur('range', 'produit'))
		:node(creerListeSimple(args, data.produit, 'Produits'))

	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