模組:IncrementParams
外观
![]() | 此模块已评为alpha版,可接受第三方输入,并可用于少量页面以检查是否存在问题,但需要受到检查。欢迎提供新功能或修改其输入输出机制的建议。 |
本模組可用於增加帶有數字的模板參數名稱,方便編者於Infobox模板中加入新行數。具體使用方法請點擊頁面「編輯」按鈕後查看模組代碼中的註釋。
使用方法
由于模板的工作方式,您不能以正常方式将模板输入传递给这个模块,而是必须直接编辑模块页面以获得所需的结果。请遵循模块代码中列出的七个步骤。
当您完成了对模块的编辑后,您就可以使用以下代码以在任何页面上使用它:
{{subst:#invoke:IncrementParams|main}}
您也可以使用pre
参数将其以预格式化文本(pre-formatted text)呈现。警告:这不适用于替换引用。
{{#invoke:IncrementParams|main|pre=yes}}
您还可以简单地复制和粘贴下方的代码:
輸出
本模組現時輸出以下內容:
| label104 = [[xtools:ec/zh.wikipedia.org/{{ROOTPAGENAME}}|{{color|{{{fontcolor|}}}|編輯統計}}]] | data104 = {{{edit_count|}}} | label105 = {{#if:{{{permissions|}}}|[[Special:UserRights/{{ROOTPAGENAMEE}}|權限]]}} | data105 = {{{permissions|}}} | label106 = 簽名 | data106 = {{{signature|}}} | data107 = {{{module|}}} | data108 = {{{module2|}}} | data109 = {{{module3|}}} | header110 = {{#if:{{{userboxes|}}}|用戶框}} | data111 = {{#if:{{{userboxes|}}}| <div style="margin: 0 auto; color: {{{fontcolor|#000000}}}; vertical-align: middle !important; text-align: center; font-size: 95%;"> {{{userboxes|}}} </div> }} | header112 = {{{custom_header|}}} | data113 = {{#if:{{{custom_data|}}}|<div style="text-align: left"> {{{custom_data|}}} </div>}} | label114 = {{{custom_label1|}}} | data114 = {{{custom_data1|}}} | label115 = {{{custom_label2|}}} | data115 = {{{custom_data2|}}} | label116 = {{{custom_label3|}}} | data116 = {{{custom_data3|}}} | label117 = {{{custom_label4|}}} | data117 = {{{custom_data4|}}} | label118 = {{{custom_label5|}}} | data118 = {{{custom_data5|}}} | label119 = {{{custom_label6|}}} | data119 = {{{custom_data6|}}} | label120 = {{{custom_label7|}}} | data120 = {{{custom_data7|}}} | label121 = {{{custom_label8|}}} | data121 = {{{custom_data8|}}} | label122 = {{{custom_label9|}}} | data122 = {{{custom_data9|}}} }}<noinclude> {{Documentation}}</noinclude>
參見
-- 第一步:點擊頁面頂部「編輯」按鈕開始編輯本模組。
-- STEP 1: Click on the "edit" tab at the top of the page to edit this module.
-- 第二步:如果你想加上1以上的數目,請修改等號後的數字。
-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign.
local increment = 6
-- 第三步:用你想增加數字的模板部分替換下方內容。
-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
| label98 = [[xtools:ec/zh.wikipedia.org/{{ROOTPAGENAME}}|{{color|{{{fontcolor|}}}|編輯統計}}]]
| data98 = {{{edit_count|}}}
| label99 = {{#if:{{{permissions|}}}|[[Special:UserRights/{{ROOTPAGENAMEE}}|權限]]}}
| data99 = {{{permissions|}}}
| label100 = 簽名
| data100 = {{{signature|}}}
| data101 = {{{module|}}}
| data102 = {{{module2|}}}
| data103 = {{{module3|}}}
| header104 = {{#if:{{{userboxes|}}}|用戶框}}
| data105 = {{#if:{{{userboxes|}}}|
<div style="margin: 0 auto; color: {{{fontcolor|#000000}}}; vertical-align: middle !important; text-align: center; font-size: 95%;">
{{{userboxes|}}}
</div>
}}
| header106 = {{{custom_header|}}}
| data107 = {{#if:{{{custom_data|}}}|<div style="text-align: left">
{{{custom_data|}}}
</div>}}
| label108 = {{{custom_label1|}}}
| data108 = {{{custom_data1|}}}
| label109 = {{{custom_label2|}}}
| data109 = {{{custom_data2|}}}
| label110 = {{{custom_label3|}}}
| data110 = {{{custom_data3|}}}
| label111 = {{{custom_label4|}}}
| data111 = {{{custom_data4|}}}
| label112 = {{{custom_label5|}}}
| data112 = {{{custom_data5|}}}
| label113 = {{{custom_label6|}}}
| data113 = {{{custom_data6|}}}
| label114 = {{{custom_label7|}}}
| data114 = {{{custom_data7|}}}
| label115 = {{{custom_label8|}}}
| data115 = {{{custom_data8|}}}
| label116 = {{{custom_label9|}}}
| data116 = {{{custom_data9|}}}
}}<noinclude>
{{Documentation}}</noinclude>
]==========]
-- 第四步:保存本模組。
-- STEP 4: Save this module.
-- 第五步:你現在可以通過以下代碼輸出數字增加後的代碼:
-- {{subst:#invoke:IncrementParams|main}}
-- 又或者直接拷貝下方模組文檔中的修改後的代碼。
-- STEP 5: You can now output the incremented text with the following code:
-- {{subst:#invoke:IncrementParams|main}}
-- Or you can simply copy and paste the text from this module's documentation.
-- 第六步:檢查輸出內容!在某些情況下本模組可能會產生部分假陽性結果。
-- 比如它會將「[[Some link|foo3=bar]]」修改為「[[Some link|foo4=bar]]」。
-- 你可以通過模板編輯頁面中「顯示變更」按鈕檢查是否有假陽性結果存在。
-- STEP 6: Check the output! In rare cases this module might produce false positives.
-- For example, it will change the text "[[Some link|foo3=bar]]" to "[[Some link|foo4=bar]]".
-- You can use the "show changes" function in the edit window of the template you are editing
-- to find any false positives.
-- 第七步:當你完成後,撤回你於本模組的編輯,避免下一個使用本模組的人對使用方法感到混淆。
-- 謝謝使用本模組!
-- STEP 7: When you are finished, undo your changes to this page, so that the next person
-- won't be confused by seeing any non-default values. Thanks for using this module!
local p = {}
local function replace(prefix, num, suffix)
return '|' .. prefix .. tostring(tonumber(num) + increment) .. suffix .. '='
end
function p.main(frame)
-- Increment the template text.
templatetext = mw.ustring.gsub(templatetext, '|(%s*%a?[%a_%-]-%s*)([1-9]%d*)(%s*[%a_%-]-%a?%s*)=', replace)
-- Add pre tags and escape html etc. if the pre option is set.
if frame and frame.args and frame.args.pre and frame.args.pre ~= '' then
templatetext = mw.text.nowiki(templatetext)
templatetext = '<pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; '
.. 'white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">'
.. templatetext .. '</pre>'
end
return templatetext
end
return p