模組:If mobile

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