Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:Nálepka

-- @brief
--  Backend for {{Nálepka}}.
-- 
-- @author
--  [[meta:User:Danny B.]]
local _module = {}
----------------------------------------


local Error = require( "Module:Error" )


-- @brief
--  Write the userbox.
-- 
-- @param
--  frame The current frame object
-- 
-- @return
--  Preprocessed wikitext
function _module.print( frame )
	
	local output = ""
	local parentFrame = frame:getParent()
	local templateArgs = {}
	local errorData = { template = "Nálepka" }
	
	local style = ""
	
	
	for param, value in pairs( parentFrame.args ) do
		templateArgs[param] = mw.text.trim( value ) ~= "" and value or nil
	end
	
	if not templateArgs["info"] then
		errorData.missingValue = { paramName = "info", paramDesc = "text nálepky" }
		output = output .. Error.getMessage( errorData )
	end
	
	if output == "" then
		
		output = output .. "<table class=\"userbox\""
		output = templateArgs["barva rámečku"] and output .. " style=\"border-color: " .. templateArgs["barva rámečku"] .. ";\"" or output
		output = output .. ">\n"
		
		output = output .. "<tr>\n"
		
		if templateArgs["levé id"] then
			output = output .. "<td class=\"userbox_id\""
			style = templateArgs["barva pozadí levého id"] and style .. "background-color: " .. templateArgs["barva pozadí levého id"] .. ";" or style
			style = templateArgs["barva textu levého id"] and style .. "color: " .. templateArgs["barva textu levého id"] .. ";" or style
			output = style ~= "" and output .. " style=\"" .. style .. "\"" or output
			output = output .. ">" .. templateArgs["levé id"] .. "</td>\n"
		end
		
		style = ""
		
		output = output .. "<td class=\"userbox_info\""
		style = templateArgs["barva pozadí infa"] and style .. "background-color: " .. templateArgs["barva pozadí infa"] .. ";" or style
		style = templateArgs["barva textu infa"] and style .. "color: " .. templateArgs["barva textu infa"] .. ";" or style
		output = style ~= "" and output .. " style=\"" .. style .. "\"" or output
		output = output .. ">" .. templateArgs["info"] .. "</td>\n"
		
		style = ""
		
		if templateArgs["pravé id"] then
			output = output .. "<td class=\"userbox_id\""
			style = templateArgs["barva pozadí pravého id"] and style .. "background-color: " .. templateArgs["barva pozadí pravého id"] .. ";" or style
			style = templateArgs["barva textu pravého id"] and style .. "color: " .. templateArgs["barva textu pravého id"] .. ";" or style
			output = style ~= "" and output .. " style=\"" .. style .. "\"" or output
			output = output .. ">" .. templateArgs["pravé id"] .. "</td>\n"
		end
		
		output = output .. "</tr>\n"
		
		output = output .. "</table>"
		
	end
	
	output = frame:preprocess( output )
	
	return output
	
end


----------------------------------------
return _module