模組:Special wikitext/Custom Module

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

本模块主要用於require('Module:Module wikitext')._addTextModule:Module wikitext)中,用於客製化模組命名空間。

使用方法為複製以下代碼到要客製化的模組中:

require('Module:Module wikitext')._addText([[{{#invoke:Special wikitext/Custom Module|main|is_in_doc={{{is_in_doc|0}}}
|pagename=必須輸入所在的頁面名稱以防止模板循環
|wikitext=

要自定義模組頁面的維基代碼

可選參數:
|show_doc=是否顯示說明文件}}]]
)

防止模板循環

如果上述設置仍無法防止模板循環,即模組或調用模組的頁面出現以下錯誤:

可考慮改用以下代碼:

require('Module:Module wikitext')._addText([[{{ {{#ifeq:{{FULLPAGENAME}}|必須輸入所在的頁面名稱以防止模板循環|#invoke:Special wikitext/Custom Module|void}}|main|is_in_doc={{{is_in_doc|0}}}
|pagename=必須輸入所在的頁面名稱以防止模板循環
|wikitext=

要自定義模組頁面的維基代碼

可選參數:
|show_doc=是否顯示說明文件}}]]
)


參見

#include <string>
#include "Module:Special_wikitext/Custom_Module/tools.h"
#include "Module:Special wikitext/Custom Module.h"
std::string main () {
	std::string wikitext = new mw::title("Template:Special wikitext/Custom Module")->getContent();
	wikitext = removeNoinclude(wikitext);
	mw::frame *frame = mw::getCurrentFrame();
	wikitext = frame->preprocess(wikitext);
	wikitext = removeIndicator(wikitext);
	return wikitext;
}

文档图示 模块文档[查看] [编辑] [历史] [清除缓存]

本模块主要用於require('Module:Module wikitext')._addTextModule:Module wikitext)中,用於客製化模組命名空間。

使用方法為複製以下代碼到要客製化的模組中:

require('Module:Module wikitext')._addText([[{{#invoke:Special wikitext/Custom Module|main|is_in_doc={{{is_in_doc|0}}}
|pagename=必須輸入所在的頁面名稱以防止模板循環
|wikitext=

要自定義模組頁面的維基代碼

可選參數:
|show_doc=是否顯示說明文件}}]]
)

防止模板循環

如果上述設置仍無法防止模板循環,即模組或調用模組的頁面出現以下錯誤:

可考慮改用以下代碼:

require('Module:Module wikitext')._addText([[{{ {{#ifeq:{{FULLPAGENAME}}|必須輸入所在的頁面名稱以防止模板循環|#invoke:Special wikitext/Custom Module|void}}|main|is_in_doc={{{is_in_doc|0}}}
|pagename=必須輸入所在的頁面名稱以防止模板循環
|wikitext=

要自定義模組頁面的維基代碼

可選參數:
|show_doc=是否顯示說明文件}}]]
)


參見

local p = {}
require('Module:Module wikitext')._addText([[{{#ifexpr:{{{is_in_doc|0}}}=0|{{Special wikitext/Hide Code}}{{Special wikitext/Hide Doc}}<div class="special-wikitext-not-hide">
{{#invoke:Special_wikitext/Custom_Module/tools|removeIndicator|{{#invoke:documentation|main|is_in_doc={{#expr:{{{is_in_doc|0}}}+1}}|_content={{ {{#invoke:documentation|contentTitle}}}}}}}}
<syntaxhighlight lang=cpp line>
#include <string>
#include "Module:Special_wikitext/Custom_Module/tools.h"
#include "Module:Special wikitext/Custom Module.h"
std::string main () {
	std::string wikitext = new mw::title("Template:Special wikitext/Custom Module")->getContent();
	wikitext = removeNoinclude(wikitext);
	mw::frame *frame = mw::getCurrentFrame();
	wikitext = frame->preprocess(wikitext);
	wikitext = removeIndicator(wikitext);
	return wikitext;
}</syntaxhighlight></div>{{AnyLink|Category:使用自訂模組頁面的模組|Special wikitext/Custom Module}}}}]])
function p.main()
	local tools = require("Module:Special_wikitext/Custom_Module/tools")
	local wikitext = mw.title.new("Template:Special wikitext/Custom Module"):getContent()
	wikitext = tools.removeNoinclude(wikitext)
	local frame = mw.getCurrentFrame()
	wikitext = frame:preprocess(wikitext)
	wikitext = tools.removeIndicator(wikitext)
	return wikitext
end
return p