분류:
Install PlaycityMap module |
Install PlaycityMap module |
||
| 12번째 줄: | 12번째 줄: | ||
end | end | ||
local function | local function buildTagAttributes(args) | ||
local base = normalizeArg(args.base) | local attrs = {} | ||
local base = normalizeArg(args.base) | |||
if base then | |||
attrs.base = base | |||
end | |||
if normalizeArg(args.mode) then | if normalizeArg(args.mode) then | ||
attrs.mode = args.mode | |||
end | end | ||
if normalizeArg(args.x) then | if normalizeArg(args.x) then | ||
attrs.x = args.x | |||
end | end | ||
if normalizeArg(args.z) then | if normalizeArg(args.z) then | ||
attrs.z = args.z | |||
end | end | ||
if normalizeArg(args.center) then | if normalizeArg(args.center) then | ||
attrs.center = args.center | |||
end | end | ||
if normalizeArg(args.zoom) then | if normalizeArg(args.zoom) then | ||
attrs.zoom = args.zoom | |||
end | end | ||
local controlValue = normalizeArg(args.control) or normalizeArg(args.controls) or normalizeArg(args.interactive) | local controlValue = normalizeArg(args.control) or normalizeArg(args.controls) or normalizeArg(args.interactive) | ||
if controlValue then | if controlValue then | ||
attrs.control = controlValue | |||
end | end | ||
if normalizeArg(args.marker) then | if normalizeArg(args.marker) then | ||
attrs.marker = args.marker | |||
end | end | ||
if normalizeArg(args.hash) then | if normalizeArg(args.hash) then | ||
attrs.hash = args.hash | |||
end | end | ||
attrs.width = normalizeArg(args.width) or "100%" | |||
attrs.height = normalizeArg(args.height) or "420" | |||
attrs.loading = normalizeArg(args.loading) or "lazy" | |||
attrs.referrerpolicy = normalizeArg(args.referrerpolicy) or "no-referrer-when-downgrade" | |||
return attrs | |||
end | end | ||
function p.embed(frame) | function p.embed(frame) | ||
local args = (frame.getParent and frame:getParent() or frame).args or {} | local args = (frame.getParent and frame:getParent() or frame).args or {} | ||
local | local tag = mw.html.create("playcitymap") | ||
local attrs = buildTagAttributes(args) | |||
for key, value in pairs(attrs) do | |||
local | tag:attr(key, value) | ||
end | |||
return tostring(tag) | |||
:attr( | |||
return tostring( | |||
end | end | ||
return p | return p | ||
2025년 12월 19일 (금) 16:58 기준 최신판
이 모듈에 대한 설명문서는 모듈:PlaycityMap/설명문서에서 만들 수 있습니다
local p = {}
local function normalizeArg(value)
if value == nil then
return nil
end
local text = tostring(value)
if text == "" then
return nil
end
return text
end
local function buildTagAttributes(args)
local attrs = {}
local base = normalizeArg(args.base)
if base then
attrs.base = base
end
if normalizeArg(args.mode) then
attrs.mode = args.mode
end
if normalizeArg(args.x) then
attrs.x = args.x
end
if normalizeArg(args.z) then
attrs.z = args.z
end
if normalizeArg(args.center) then
attrs.center = args.center
end
if normalizeArg(args.zoom) then
attrs.zoom = args.zoom
end
local controlValue = normalizeArg(args.control) or normalizeArg(args.controls) or normalizeArg(args.interactive)
if controlValue then
attrs.control = controlValue
end
if normalizeArg(args.marker) then
attrs.marker = args.marker
end
if normalizeArg(args.hash) then
attrs.hash = args.hash
end
attrs.width = normalizeArg(args.width) or "100%"
attrs.height = normalizeArg(args.height) or "420"
attrs.loading = normalizeArg(args.loading) or "lazy"
attrs.referrerpolicy = normalizeArg(args.referrerpolicy) or "no-referrer-when-downgrade"
return attrs
end
function p.embed(frame)
local args = (frame.getParent and frame:getParent() or frame).args or {}
local tag = mw.html.create("playcitymap")
local attrs = buildTagAttributes(args)
for key, value in pairs(attrs) do
tag:attr(key, value)
end
return tostring(tag)
end
return p