模組:If mobile

出自微國家百科
於 2024年6月25日 (二) 09:21 由 LarryChou留言 | 貢獻 所做的修訂 (建立內容為「local p = {} function p._main(args) local frame = mw.getCurrentFrame() local root = mw.html.create() if args["Tag"] then args["tag"] = args["Tag"] end local ifmobile = root:tag(args["tag"] or 'span') ifmobile :addClass('ifmobile') local nomobile = ifmobile:tag(args["tag"] or 'span') local mobile = ifmobile:tag(args["tag"] or 'span') nomobile :addClass('nomobile') :wikitext(args[2])…」的新頁面)
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)

可在模組:If mobile/doc建立此模組的說明文件

local p = {}

function p._main(args)
    local frame = mw.getCurrentFrame()
    local root = mw.html.create()

    if args["Tag"] then
        args["tag"] = args["Tag"]
    end

    local ifmobile = root:tag(args["tag"] or 'span')
    ifmobile
        :addClass('ifmobile')

    local nomobile = ifmobile:tag(args["tag"] or 'span')
    local mobile = ifmobile:tag(args["tag"] or 'span')

    nomobile
        :addClass('nomobile')
        :wikitext(args[2])

    mobile
        :addClass('mobile')
        :wikitext(args[1])

    return frame:extensionTag {name = 'templatestyles', args = {src = 'If mobile/styles.css'}} .. tostring(root)
end

function p.main(frame)
    local args = require('Module:Arguments').getArgs(frame, {
        wrappers = 'Template:If mobile'
    })
    return p._main(args)
end

return p