模組:Module wikitext/CGroup

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书
文档图示 模块文档[查看] [编辑] [历史] [清除缓存]

本模組為提供Module:CGroup實現{{Special wikitext}}中的Module:Module wikitext功能所架設。能讓轉換組能加入自訂的wikitext並納入分類,以方便諸如提刪或掛維護模板之功能。詳細使用方法請參考Module:Module wikitext/doc

本模組的主模組Module:Module wikitext被引用於MediaWiki:Scribunto-doc-page-does-not-exist嵌入於所有模組因此被全保護;而本子模版只嵌入了所有公共轉換組,因此只被半保護。

如公共轉換組在調用本模組的位置出現錯誤,請檢查Module:Documentation中的getEnvironment_getModuleWikitext是否被刪除或更名,如是,請更新本模組或回退Module:Documentation中的相關更改。

--模組用於提供轉換組加上分類的支援
local p = {}
local lib_arg = {}

function p.main(frame)
	local args, working_frame
    if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        if lib_arg.getArgs == nil then lib_arg = require('Module:Arguments') end
        args = lib_arg.getArgs(frame)
        working_frame = frame
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        working_frame = mw.getCurrentFrame()
        if type(args) ~= type({}) then args = {frame} end
    end
    local root = mw.html.create()
    local lib_doc = require('Module:Documentation')
    local env = lib_doc.getEnvironment(args)
    root:wikitext(lib_doc._getModuleWikitext(args, env))
	return tostring(root)
end

return p