모듈:Deck: 두 판 사이의 차이
외관
잔글편집 요약 없음 |
잔글편집 요약 없음 |
||
| 1번째 줄: | 1번째 줄: | ||
local p = {} | local p = { | ||
keys = { | |||
'' | |||
} | |||
} | |||
function p.render(f) | function p.render(f) | ||
| 14번째 줄: | 18번째 줄: | ||
if line ~= '' then | if line ~= '' then | ||
local key, value = line:match('^([ | local key, value = line:match('^([%w%s]+)=(.+)$') | ||
if key and value then | if key and value then | ||
key = mw.text.trim(key):lower() | key = mw.text.trim(key):lower() | ||
2026년 5월 26일 (화) 22:01 판
이 모듈에 대한 설명문서는 모듈:Deck/설명문서에서 만들 수 있습니다
local p = {
keys = {
''
}
}
function p.render(f)
local args = f:getParent().args
if args['items'] == nil then
args = f.args
end
local lines = (args['items'] or ''):gmatch("([^\n]+)")
local items = {}
for line in lines do
line = mw.text.trim(line)
if line ~= '' then
local key, value = line:match('^([%w%s]+)=(.+)$')
if key and value then
key = mw.text.trim(key):lower()
value = mw.text.trim(value)
if key ~= '' then
items[#items][key] = value
end
else
table.insert(items, {url = line})
end
end
end
-- HTML
local html = ''
for _, item in ipairs(items) do
local url = item.url or '#'
local icon = item.icon or ''
local title = mw.text.trim(item.title or '')
local iconSpan = mw.html.create('span'):wikitext(icon)
local contentSpan = mw.html.create('span'):wikitext(title)
html = html ..'[' .. url .. ' ' .. tostring(iconSpan) .. tostring(contentSpan) .. ']'
end
return f:preprocess('<div class="kawa-deck">' .. html .. '</div>')
end
return p