模块:PackedGallery

来自生物多样性知识平台

Lizc讨论 | 贡献2024年5月3日 (五) 10:17的版本 (创建页面,内容为“local p = {} function p.renderGallery(frame) local images = frame.args.images or "" local imageList = mw.text.split(images, ",") local galleryCode = '<gallery mode="packed" widths="120px">\n' for i, image in ipairs(imageList) do local parts = mw.text.split(image, ";") local fileName = parts[1] or "" local fileDesc = parts[2] or "" galleryCode = galleryCode .. string.format('File:%s|%s\n', mw.text.trim(fileName),…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

可在模块:PackedGallery/doc创建此模块的帮助文档

local p = {}

function p.renderGallery(frame)
    local images = frame.args.images or ""
    local imageList = mw.text.split(images, ",")
    local galleryCode = '<gallery mode="packed" widths="120px">\n'

    for i, image in ipairs(imageList) do
        local parts = mw.text.split(image, ";")
        local fileName = parts[1] or ""
        local fileDesc = parts[2] or ""
        galleryCode = galleryCode .. string.format('File:%s|%s\n', mw.text.trim(fileName), mw.text.trim(fileDesc))
    end

    galleryCode = galleryCode .. '</gallery>'
    return galleryCode
end

return p