模板:Count

被永久保護的模板
維基百科,自由的百科全書

0

文件圖示 模板文件[檢視] [編輯] [歷史] [清除快取]

概要

本模板返回傳入參數的數量,最多支持10個參數。當沒有參數傳入時返回base(默認為0)

參數及使用方法

Set base=0 or base=1 to change from the default value returned if there are no defined parameters.  (i.e. If no defined parameters, returns 0 by default (or 1 if base=1))

範例

Note: {{ Count/testcase1}} tests nesting of templates calling {{ Count}}.

輸入 輸出
{{ Count| A| B| | D}} 3
{{ Count/testcase1}} 0
{{ Count/testcase1| base=1}} 1
{{ Count/testcase1| base=0}} 0
{{ Count/testcase1| abc}} 1
{{ Count/testcase1| abc| base=0}} 1
{{ Count/testcase1| abc| base=1}} 1
{{ Count/testcase1| | DEF}} 1
{{ Count/testcase1| abc| DEF}} 2
{{ Count/testcase1| abc| DEF| }} 2
{{ Count/testcase1| abc| DEF| ghi}} 3
{{ Count/testcase1| abc| | ghi}} 2
{{ Count/testcase1| abc| DEF| ghi| JKL| mno| PQR| stu| VWX| yz#}} 9
{{ Count/testcase1| abc| DEF| ghi| JKL| mno| PQR| stu| VWX| yz@|  #$%}} 10
{{ Count/testcase1| abc| DEF| ghi| JKL| mno| PQR| stu| VWX| yz@|  #$%| ^&*| ()_| +:"| 123| 456| 789| 000}} 10   最多只支持10個參數
{{ Count/testcase1| abc| | ghi| | mno| | stu| | yz@| }} 5
{{ Count/testcase1| | DEF| | JKL| | PQR| | VWX| |  #$%}} 5
{{ Count/testcase1| DEF| JKL| PQR| VWX|  #$%}} 5
{{ Count/testcase1| | | | | | | | | |  #$%}} 1
{{ Count/testcase1| | | | | | | | | }} 0
{{ Count/testcase1| | | | | | | | | | base=0}} 0
{{ Count/testcase1| | | | | | | | | | base=1}} 1
{{ Count/testcase1| base=0| | | | | | | | | }} 0
{{ Count/testcase1| base=1| | | | | | | | | }} 1
{{ Count/testcase1| base=0| | | | | | PQR| | | }} 1
{{ Count/testcase1| base=1| | | | | | PQR| | | }} 1

注意事項

重定向

模板編輯說明

參見