模組:Unsubst/doc
这是Module:Unsubst的文档页面
此模塊可防止模板和模塊被錯誤替換。
用法[编辑]
首先,將以下內容放在模塊中entry_point
函數的開頭:
if mw.isSubsting() then
return require('Module:unsubst').unsubst_template("entry_point")
end
其中"entry_point"
應該替換為函數名。接下來,編輯模板:
{{safesubst:<noinclude/>#invoke:...|entry_point|...}}
<noinclude/>
是可選的。模板將替換為其被嵌入的形式。
如果要保護模塊本身而不是模板,請在函數開始處添加:
if mw.isSubsting() then
return require('Module:unsubst').unsubst_module("entry_point")
end
直接在模板中使用[编辑]
您可以將模板代碼包裹在如下代码中:
{{safesubst:#invoke:unsubst|me|= ... }}
結果同上述unsubst_template
,另外還會生成對Module:Unsubst的嵌入。此外,它还可以防止模板被複製粘貼到非模板頁面。