모듈:Optional style
보이기
| 위 설명은 모듈:Optional style/설명문서의 내용을 가져와 보여주고 있습니다. (편집 | 역사) 연습장 (생성 | 복제) 및 시험장 (생성) 문서에서 이 모듈을 실험할 수 있습니다. 이 모듈에 딸린 문서. |
--[=[
Simple module to construct a style attribute
with an undefined number (including zero) of CSS properties
]=]
local p = {} --p stands for package
local getArgs = require('Module:Arguments').getArgs
--[=[
Construct the string from the given table of property:values
]=]
function p.make_style_string(properties)
local out = ''
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
Arguments are taken from both frame and parent argument lists
]=]
function p.optional_style(frame)
local args = getArgs(frame)
return p.make_style_string(args)
end
return p