模組:Special wikitext/Template
外观
![]() | 此模块被引用於MediaWiki:Gadget-SpecialWikitext.js與MediaWiki:Clearyourcache中。 任何對此模块的修改會立即反映於維基百科的用户介面。 為了避免造成大規模的影響,编者可以在本模块的沙盒 和测试样例 页面进行实验。 測試後無誤的版本可以一次性地加入此模块中,但是修改前請務必於討論頁發起討論。 |
local p={}
--{{#invoke:Special wikitext/Template|contentModel}}
function p.contentModel(frame)
local page_name = frame.args[1] or frame.args['1'] or ''
local page_data = (mw.text.trim(page_name)==''and mw.title.getCurrentTitle() or mw.title.new(page_name))
return page_data.contentModel
end
--{{#invoke:Special wikitext/Template|luaContentFromPage}}
function p.luaContentFromPage(frame)
local page_name = frame.args[1] or frame.args['1'] or ''
local page_data = (mw.text.trim(page_name)==''and mw.title.getCurrentTitle() or mw.title.new(page_name))
local contentModel = mw.ustring.lower(page_data.contentModel)
if contentModel == 'scribunto' or contentModel == 'lua' then
pcall(require, page_data.prefixedText) -- if it fails, we don't care
local moduleWikitext = package.loaded["Module:Module wikitext"]
if moduleWikitext then
return moduleWikitext.main()
end
end
return ''
end
return p