Difference between revisions of "Template:List lookup helper/sublist case"
Jump to navigation
Jump to search
Kevin Wang (talk | contribs) m |
Kevin Wang (talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | <includeonly>{{#vardefine:jj| | + | <includeonly>{{#vardefine:jj|1}}{{#loop:ii|1|{{#var:sublist_index}}<!-- |
Initialize jj = 1 - this will be the global counter for entries. | Initialize jj = 1 - this will be the global counter for entries. | ||
Iterate from 1 -> sublist_index to visit all sublists. | Iterate from 1 -> sublist_index to visit all sublists. | ||
| − | + | >> LOOP 1 START | |
| − | |||
| − | |||
| − | |||
Update current_sublist and cleaned_sublist using the current sublist. | Update current_sublist and cleaned_sublist using the current sublist. | ||
| − | -->{{ | + | -->|{{#vardefine:current_sublist|{{#var:sublist_{{#var:ii}}}}}}{{#vardefine:cleaned_sublist|{{#explode:{{#var:current_sublist}}|==|0}}}}<!-- |
| + | >>>> LOOP 2 START | ||
| + | Walk through the list of entries in this sublist and set entry_jj for each. | ||
jj++ | jj++ | ||
| − | |||
| + | -->{{#while: | ||
| + | |{{#explode:{{#var:cleaned_sublist}}|*|{{#var:jj}}|1000}} | ||
| + | |{{#vardefine:entry_{{#var:jj}}|{{#explode:{{#var:cleaned_sublist}}|*|{{#var:jj}}|1000}}}}{{Add|jj|1}} | ||
| + | }}<!-- | ||
| + | <<<< LOOP 2 END | ||
-->}}<!-- | -->}}<!-- | ||
| − | + | << LOOP 1 END | |
| − | + | Set length to be jj - 1. | |
| − | + | -->{{#vardefine:length|{{#expr:{{#var:jj}}-1}}}}</includeonly><noinclude> | |
| − | |||
| − | -->{{#vardefine:length|{{#var:jj}}}}</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 31: | Line 32: | ||
<pre> | <pre> | ||
| + | {{Sublist| | ||
| + | * 1 | ||
| + | * 2 | ||
| + | }} | ||
{{List lookup helper/sublist case}} | {{List lookup helper/sublist case}} | ||
| − | {{#var:length}} | + | {{#var:length}}: {{#var:entry_1}}, {{#var:entry_2}} |
</pre> | </pre> | ||
| − | + | {{Sublist| | |
| + | * 1 | ||
| + | * 2 | ||
| + | }} | ||
{{List lookup helper/sublist case}} | {{List lookup helper/sublist case}} | ||
| − | {{#var:length}} | + | {{#var:length}}: {{#var:entry_1}}, {{#var:entry_2}} |
}}</noinclude> | }}</noinclude> | ||
Revision as of 17:35, 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
}}
{{List lookup helper/sublist case}}
{{#var:length}}: {{#var:entry_1}}, {{#var:entry_2}}
- 1
- 2
2: 1, 2