Difference between revisions of "Expandpages"
From Sega Retro
(Created page with "<includeonly>{{#vardefine:expandpagesresult|}} {{#loop: chunknum |0 |{{#expr:{{charcount|{{{1}}}|,}}+1}} |{{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var:chunknum}}}}}} {{#if:...") |
m (Text replacement - "Category:Sega Retro templates" to "Category:Templates") |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | <includeonly>{{#vardefine: | + | <includeonly>{{clearvar|epresult}}{{#vardefine:epn|0}}{{#while: |
− | {{# | + | | {{#ifexpr: {{#len:{{#explode:{{{1}}}|,|{{#var:epn}}}}}} > 0 | true }} |
− | + | | {{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var:epn}}}}}} | |
− | |{{# | + | {{#vardefine:epresult|{{#if: {{#pos:{{#var:chunk}}|-}} |
− | |{{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var: | + | | {{#var:epresult}}{{#vardefine:s1|{{#explode:{{#var:chunk}}|-|0}}}}{{#vardefine:s2|{{#explode:{{#var:chunk}}|-|1}}}}{{#loop: s | {{#var:s1}} | {{#expr:{{#var:s2}}-{{#var:s1}}+1}} | ,{{#var:s}}}} |
− | + | | {{#var:epresult}},{{#var:chunk}} | |
− | | {{#vardefine:s1|{{#explode:{{#var:chunk}}|-|0}}}}{{#vardefine:s2|{{#explode:{{#var:chunk}}|-|1}}}} | + | }}}}{{incvar|epn}}}}{{#sub:{{#var:epresult}}|1}}</includeonly><noinclude> |
− | + | Convert a range of pages given by the format "a-c" into a format the [[Template:Gallery|gallery template]] can cope with. That is, "a-c" becomes a,b,c. | |
− | |||
− | |||
− | }}{{ | ||
− | Convert a range of pages given by the format "a-c" into a format | ||
Example: <nowiki>{{expandpages|12-14}}</nowiki> becomes {{expandpages|12-14}}. | Example: <nowiki>{{expandpages|12-14}}</nowiki> becomes {{expandpages|12-14}}. | ||
Line 16: | Line 12: | ||
Example: <nowiki>{{expandpages|12-14,17,20-21}}</nowiki> becomes {{expandpages|12-14,17,20-21}}. | Example: <nowiki>{{expandpages|12-14,17,20-21}}</nowiki> becomes {{expandpages|12-14,17,20-21}}. | ||
− | [[Category: | + | [[Category:Templates]]</noinclude> |
Latest revision as of 12:54, 1 January 2022
Convert a range of pages given by the format "a-c" into a format the gallery template can cope with. That is, "a-c" becomes a,b,c.
Example: {{expandpages|12-14}} becomes 12,13,14.
Example: {{expandpages|12-14,17,20-21}} becomes 12,13,14,17,20,21.