Template:Row numbers/doc: Difference between revisions
en>GKFX use {{warning nowiki broken}} |
en>GKFX Remove <nowiki> from examples (but leave it mentioned in TemplateData) |
||
| Line 11: | Line 11: | ||
"1": { | "1": { | ||
"label": "the wikitable", | "label": "the wikitable", | ||
"description": "the wiki table surrounded by <nowiki>… </nowiki> tags", | "description": "Either the whole wiki table surrounded by <nowiki>… </nowiki> tags, or the first section, when split by {{!}} characters", | ||
"type": "string", | "type": "string", | ||
"required": true, | "required": true, | ||
| Line 30: | Line 30: | ||
} }} | } }} | ||
This template takes | This template takes an arbitrary number of parameters: the table and the starting index. There is a caveat: the table is wrapped in the template without escaping the <code>|</code> characters. The module is capable of dealing with this, but it is not capable of dealing with bare equals signs at the same time. As such, bare equals signs must still be escaped with {{tl|=}}. Internally, the Module maintains a monotonically increasing counter. The Module looks for the keywords <code>_row_count</code> and <code>_row_count_hold</code> in the table. Keyword <code>_row_count</code> is replaced with the next counter value; keyword <code>_row_count_hold</code> is replaced with the value from the last <code>_row_count</code> replacement. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 37: | Line 37: | ||
! Visual effect !! Markup | ! Visual effect !! Markup | ||
|- | |- | ||
| {{row numbers| | | {{row numbers| | ||
{| class="wikitable" | {| class{{=}}"wikitable" | ||
|+test incrementor | |+test incrementor | ||
!count !! lorem | !count !! lorem | ||
| Line 51: | Line 51: | ||
|- | |- | ||
|_row_count || {{Str left|{{Lorem ipsum}}|123}} | |_row_count || {{Str left|{{Lorem ipsum}}|123}} | ||
|} | |}}} | ||
|| <pre> {{row numbers| | || <pre>{{row numbers| | ||
{| class="wikitable" | {| class{{=}}"wikitable" | ||
|+test incrementor | |+test incrementor | ||
!count !! lorem | !count !! lorem | ||
| Line 66: | Line 66: | ||
|- | |- | ||
|_row_count || {{Str left|{{Lorem ipsum}}|123}} | |_row_count || {{Str left|{{Lorem ipsum}}|123}} | ||
|} | |}}}</pre> | ||
|- | |- | ||
| {{row numbers| | | {{row numbers| | ||
{| class="wikitable" | {| class{{=}}"wikitable" | ||
|+test incrementor | |+test incrementor | ||
!count !! lorem | !count !! lorem | ||
| Line 82: | Line 82: | ||
|- | |- | ||
|_row_count || {{Str left|{{Lorem ipsum}}|123}} | |_row_count || {{Str left|{{Lorem ipsum}}|123}} | ||
|} | |}|index =50}} | ||
|| <pre> | || <pre>{{row numbers| | ||
{| class="wikitable" | {| class{{=}}"wikitable" | ||
|+test incrementor | |+test incrementor | ||
!count !! lorem | !count !! lorem | ||
| Line 97: | Line 97: | ||
|- | |- | ||
|_row_count || {{Str left|{{Lorem ipsum}}|123}} | |_row_count || {{Str left|{{Lorem ipsum}}|123}} | ||
|} | |} |index =50}}</pre> | ||
|} | |} | ||
<includeonly>{{sandbox other|| | <includeonly>{{sandbox other|| | ||
<!-- Categories below this line, please; interwikis at Wikidata --> | <!-- Categories below this line, please; interwikis at Wikidata --> | ||
}}</includeonly> | }}</includeonly> | ||
Revision as of 19:38, 18 October 2021
| This is a documentation subpage for Template:Row numbers. It may contain usage information, categories and other content that is not part of the original template page. |
| This template uses Lua: |
Template:Warning nowiki broken This is a stop-gap template that serves as an interface to Module:Row numbers.
This template makes it possible, in many cases, to have an incrementing row indexer/counter in a table so that adding or removing rows automatically adjusts the numbering of subsequent rows. This template will become obsolete if and when MediaWiki supports automatically adding row numbers via WikiTable syntax. See Phab: T42618 - "jquery.tablesorter: Add support for a 'fixed' column of row numbers." And see Help:Sorting, and the sections on row numbering and auto-ranking. Using Template:Row numbers is one of the methods described on that page.
Usage
TemplateData for Row numbers
INTERNAL: Module:Format_TemplateData:568: assign to undeclared variable 'dt'
This template takes an arbitrary number of parameters: the table and the starting index. There is a caveat: the table is wrapped in the template without escaping the | characters. The module is capable of dealing with this, but it is not capable of dealing with bare equals signs at the same time. As such, bare equals signs must still be escaped with {{[[Template:{{{1}}}|{{{1}}}]]}}. Internally, the Module maintains a monotonically increasing counter. The Module looks for the keywords _row_count and _row_count_hold in the table. Keyword _row_count is replaced with the next counter value; keyword _row_count_hold is replaced with the value from the last _row_count replacement.
| Visual effect | Markup | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
{{row numbers|
{| class{{=}}"wikitable"
|+test incrementor
!count !! lorem
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|-
|_row_count || {{Str left|{{Lorem ipsum}}|27}}
|-
|_row_count || {{Str left|{{Lorem ipsum}}|5}}
|-
|_row_count_hold || {{Str left|{{Lorem ipsum}}|11}}
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|}}}
| ||||||||||||
|
{{row numbers|
{| class{{=}}"wikitable"
|+test incrementor
!count !! lorem
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|-
|_row_count || {{Str left|{{Lorem ipsum}}|27}}
|-
|_row_count || {{Str left|{{Lorem ipsum}}|5}}
|-
|_row_count_hold || {{Str left|{{Lorem ipsum}}|11}}
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|} |index =50}}
|