Difference between revisions of "Template:List lookup helper/sublist case"
Jump to navigation
Jump to search
Kevin Wang (talk | contribs) |
Kevin Wang (talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | <includeonly> | + | <includeonly>{{#loop:ii|1|{{#var:sublist_index}}<!-- |
| − | |||
Iterate from 1 -> sublist_index to visit all sublists. | Iterate from 1 -> sublist_index to visit all sublists. | ||
| Line 10: | Line 9: | ||
>>>> LOOP 2 START | >>>> LOOP 2 START | ||
| − | Walk through the list of entries in this sublist and set | + | Initialize jj = 1 |
| + | Walk through the list of entries in this sublist and set entry_{length+jj}} for each. | ||
jj++ | jj++ | ||
| − | -->{{#while: | + | -->{{#vardefine:jj|1}}{{#while: |
|{{#explode:{{#var:cleaned_sublist}}|*|{{#var:jj}}|1000}} | |{{#explode:{{#var:cleaned_sublist}}|*|{{#var:jj}}|1000}} | ||
| − | |{{#vardefine:entry_{{#var:jj}}|{{#explode:{{#var:cleaned_sublist}}|*|{{#var:jj}}|1000}}}}{{Add|jj|1}} | + | |{{#vardefine:entry_{{#expr:{{#var:length}}+{{#var:jj}}}}|{{#explode:{{#var:cleaned_sublist}}|*|{{#var:jj}}|1000}}}}{{Add|jj|1}} |
}}<!-- | }}<!-- | ||
<<<< LOOP 2 END | <<<< LOOP 2 END | ||
| − | -->}}<!-- | + | -->{{Add|length|{{#expr:{{#var:jj}}-1}}}}}}<!-- |
| + | Increase length by jj - 1. | ||
<< LOOP 1 END | << LOOP 1 END | ||
| − | + | --></includeonly><noinclude> | |
| − | --> | ||
{{Template doc| | {{Template doc| | ||
Special handling for [[Template:List lookup helper]] when [[Template:Sublist]] is being used. | Special handling for [[Template:List lookup helper]] when [[Template:Sublist]] is being used. | ||
| Line 35: | Line 35: | ||
* 1 | * 1 | ||
* 2 | * 2 | ||
| + | }} | ||
| + | {{#var:length}} | ||
| + | {{Sublist| | ||
| + | * 3 | ||
| + | * 4 | ||
}} | }} | ||
{{List lookup helper/sublist case}} | {{List lookup helper/sublist case}} | ||
| − | {{#var:length}}: {{#var:entry_1}}, {{#var:entry_2}} | + | {{#var:length}} ({{#var:sublist_index}}): {{#var:entry_1}}, {{#var:entry_2}} |
</pre> | </pre> | ||
{{Sublist| | {{Sublist| | ||
* 1 | * 1 | ||
* 2 | * 2 | ||
| + | }} | ||
| + | {{#var:length}} | ||
| + | {{Sublist| | ||
| + | * 3 | ||
| + | * 4 | ||
}} | }} | ||
{{List lookup helper/sublist case}} | {{List lookup helper/sublist case}} | ||
| − | {{#var:length}}: {{#var:entry_1}}, {{#var:entry_2}} | + | {{#var:length}} ({{#var:sublist_index}}): {{#var:entry_1}}, {{#var:entry_2}}, {{#var:entry_3}}, {{#var:entry_4}} |
}}</noinclude> | }}</noinclude> | ||
Revision as of 18:32, 20 December 2025
Template documentation
Special handling for Template:List lookup helper when Template:Sublist is being used.
Is intended to be used as a special case in the above template. Expects that "loaded_page" has been defined with the contents of the target list, which should have defined the "sublist_n" variables.
Provides alternate route to:
- length
- entry_i.
{{Sublist|
* 1
* 2
}}
{{#var:length}}
{{Sublist|
* 3
* 4
}}
{{List lookup helper/sublist case}}
{{#var:length}} ({{#var:sublist_index}}): {{#var:entry_1}}, {{#var:entry_2}}
- 1
- 2
- 3
- 4
4 (2): 1, 2, 3, 4