모듈:ImageSwitch

모니터링 (토론 | 기여)님의 2025년 4월 17일 (목) 14:54 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

이 모듈에 대한 설명문서는 모듈:ImageSwitch/설명문서에서 만들 수 있습니다

local p = {}

function p.main(frame)
    local args = frame:getParent().args

    local light = args[1] or ''
    if light == '' then
        return '<strong class="error">라이트모드 이미지가 필요합니다.</strong>'
    end

    local dark = args[2] or ''

    local function wrap_img(img_code, class)
        return '<span class="' .. class .. '">' .. img_code .. '</span>'
    end

    local html = {}
    table.insert(html, '<div class="image-switch-wrapper">')
    table.insert(html, wrap_img(light, 'light-mode-img'))
    if dark ~= '' then
        table.insert(html, wrap_img(dark, 'dark-mode-img'))
    end
    table.insert(html, '</div>')

    return table.concat(html)
end

return p