跳转到内容

模組:Special wikitext/Template

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由A2569875留言 | 贡献2021年5月12日 (三) 07:23 建立内容为“local p={} --{{#invoke:Special wikitext/Template|contentModel}} function p.contentModel(frame) local page_name = frame.args[1] or frame.args['1'] o…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)

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