Module:Fermentation

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( 'div' )
		:addClass( 'artisanat-colonne-titre' )
		:wikitext( note )
		:done()
	end

function p._build(args)
	local res = mw.html.create( 'ul' )
		:addClass( 'artisanat-colonne' )
		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
	
	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