Модуль:Дадатковы стыль

З пляцоўкі Вікікрыніцы

Дакументацыю да гэтага модуля можна стварыць у Модуль:Дадатковы стыль/Дакументацыя

--[=[
Simple module to construct a style attribute with an undefined number (including
zero) of CSS properties
]=]

local p = {} --p азначае пакет
local getArgs = require('Модуль:Аргумэнты').getArgs

--[=[
Construct the string from the given table of property:values
]=]
function p.make_style_string(properties)
	
	out  = ''
	
	local num_processed = 0
	for k, v in pairs(properties) do
		if k ~= 'style' and v~= '' then
			out = out .. k .. ':' .. v .. ';'
		end
	end
	
	if properties.style ~= nil and properties.style ~= '' then
		out = out .. properties.style	
	end
	
	if out == '' then
		return ''
	end
	
	return 'style="' .. out .. '"'
end

--[=[
The main entry function from templates

Аргумэнты выбіраюцца як з уваходу, так і з бацькоўскіх
]=]
function p.optional_style(frame)
	local args = getArgs(frame)
	return p.make_style_string(args)
end

return p