Template:Row numbers/doc: Difference between revisions

From escforumwiki
Jump to navigation Jump to search
en>Manabimasu
en>Manabimasu
Line 7: Line 7:


== Usage ==
== Usage ==
 
{{Format TemplateData|JSON={
{{Format TemplateData|JSON=
"params": {
{
"params": {
"1": {
"1": {
"label": "the table",
"label": "the wikitable",
"description": "the wiki table surrounded by <nowiki>…</nowiki> tags",
"description": "the wiki table surrounded by nowiki tags",
"example": "<nowiki>
"example": "",
{| 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}}
|}</nowiki>",
"type": "string",
"type": "string",
"required": true,
"required": true,
Line 37: Line 21:
"description": "starting index of row count",
"description": "starting index of row count",
"example": "50",
"example": "50",
"type": "integer",  
"type": "number",  
"required": false,
"required": false,
"suggested": false,
"suggested": false,
             "default":0
             "default":"0"
}
}
},
},
"description": "dynamic row counter",
"description": "<noexport><code>&#123;&#123;color box striped&#124;''wikitable''&#124;''index = '' &#125;&#125;</code><br></noexport>",
"format": "inline"
"format": "inline"
} }}
} }}  


This template takes one parameter: the table and the starting index.  There is a caveat: the table {{em|must}} be wrapped inside {{tag|nowiki}} tags so that all of the pipe characters (<code>|</code>) required in a wiki table do not confuse the template into thinking that they are all individual template parameters.  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.
This template takes one parameter: the table and the starting index.  There is a caveat: the table {{em|must}} be wrapped inside {{tag|nowiki}} tags so that all of the pipe characters (<code>|</code>) required in a wiki table do not confuse the template into thinking that they are all individual template parameters.  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.

Revision as of 20:10, 18 April 2021

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

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Row numbers in articles based on its TemplateData.

TemplateData for Row numbers

INTERNAL: Module:Format_TemplateData:568: assign to undeclared variable 'dt'

This template takes one parameter: the table and the starting index. There is a caveat: the table must be wrapped inside <nowiki>...</nowiki> tags so that all of the pipe characters (|) required in a wiki table do not confuse the template into thinking that they are all individual template parameters. 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.

{{row numbers|<nowiki>
{| 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}}
|}</nowiki>}}


test incrementor
count lorem
1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
2 Lorem ipsum dolor sit amet,
3 Lorem
3 Lorem ipsum
5 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

There are further caveats. When wrapped in <nowiki>...</nowiki>, the '<' and '>' characters that begin and end all html-like markup, are replaced with &lt; and &gt; html entities respectively. Because the Module cannot know if there are html entities already in use before the table was wrapped in the <nowiki>...</nowiki> tags required here, when the module replaces the html entities with '<' and '>' characters, something may break. caveat lector.