Difference between revisions of "User:Sub4rctic/Any"
Line 19: | Line 19: | ||
</includeonly> | </includeonly> | ||
+ | <noinclude> | ||
'''<nowiki>{{User:Sub4rctic/Woods}}</nowiki>''' | '''<nowiki>{{User:Sub4rctic/Woods}}</nowiki>''' | ||
+ | |||
List of all woods with < and > as PREFIX and SUFFIX, semicolon separated | List of all woods with < and > as PREFIX and SUFFIX, semicolon separated | ||
− | {{#replace:string|search term|replacement term}} | + | <nowiki>{{#replace:string|search term|replacement term}}</nowiki> |
+ | |||
replacement syntax | replacement syntax | ||
− | {{#replace:{{User:Sub4rctic/Woods}}|search term|replacement term}} | + | <nowiki>{{#replace:{{User:Sub4rctic/Woods}}|search term|replacement term}}</nowiki> |
+ | |||
use the woods template as the string | use the woods template as the string | ||
− | {{#replace:{{User:Sub4rctic/Woods}}|>|<nowiki/> <nowiki/>SUFFIX}} | + | <nowiki>{{#replace:{{User:Sub4rctic/Woods}}|>|<nowiki/> <nowiki/>SUFFIX}}</nowiki> |
+ | |||
If a space is used in the replacement term, must be nowiki'd out with self-closing tags | If a space is used in the replacement term, must be nowiki'd out with self-closing tags | ||
− | {{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX}}|<|PREFIX}} | + | <nowiki>{{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX}}|<|PREFIX}}</nowiki> |
+ | |||
nest SUFFIX replacement inside a PREFIX replacement | nest SUFFIX replacement inside a PREFIX replacement | ||
− | {{#explode:string|delimiter|position|limit}} | + | <nowiki>{{#explode:string|delimiter|position|limit}}</nowiki> |
+ | |||
explode syntax. Pos counted from 0 | explode syntax. Pos counted from 0 | ||
− | {{#explode:{{{1}}}|,|0}} | + | <nowiki>{{#explode:{{{1}}}|,|0}}</nowiki> |
+ | |||
Returns before comma | Returns before comma | ||
− | {{#explode:{{{1}}}|,|1}} | + | <nowiki>{{#explode:{{{1}}}|,|1}}</nowiki> |
+ | |||
returns string after comma | returns string after comma | ||
− | {{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX,{{#explode:{{{1}}}|,|1}}}}|<|PREFIX}} | + | <nowiki>{{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX,{{#explode:{{{1}}}|,|1}}}}|<|PREFIX}}</nowiki> |
+ | |||
after the suffix add a comma and add param 1 string after comma. Problem: leaves a comma even when there is no ",#" after item name. | after the suffix add a comma and add param 1 string after comma. Problem: leaves a comma even when there is no ",#" after item name. | ||
− | {{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }} | + | <nowiki>{{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }}</nowiki> |
+ | |||
if syntax | if syntax | ||
− | {{#if: {{#explode:{{{1}}}|,|1}}|,{{#explode:{{{1}}}|,|1}}|}} | + | <nowiki>{{#if: {{#explode:{{{1}}}|,|1}}|,{{#explode:{{{1}}}|,|1}}|}}</nowiki> |
+ | |||
if param 1 string after comma delimiter is not empty, return ", string", and if it is, return nothing | if param 1 string after comma delimiter is not empty, return ", string", and if it is, return nothing | ||
− | {{#replace: {{#replace: {{User:Sub4rctic/Woods}}|>|SUFFIX{{#if:{{#explode:{{{1}}}|,|1}}|,{{#explode:{{{1}}}|,|1}}|}}}}|<|PREFIX}} | + | <nowiki>{{#replace: {{#replace: {{User:Sub4rctic/Woods}}|>|SUFFIX{{#if:{{#explode:{{{1}}}|,|1}}|,{{#explode:{{{1}}}|,|1}}|}}}}|<|PREFIX}}</nowiki> |
+ | |||
so if param 1 has a comma then number, a comma and the number will be placed after SUFFIX. If not, then nothing will be placed after SUFFIX | so if param 1 has a comma then number, a comma and the number will be placed after SUFFIX. If not, then nothing will be placed after SUFFIX | ||
− | {{#switch: comparison string | + | <pre>{{#switch: comparison string |
| case = result | | case = result | ||
| case = result | | case = result | ||
| #default = default result | | #default = default result | ||
− | }} | + | }}</pre> |
+ | |||
Switch syntax | Switch syntax | ||
+ | |||
+ | |||
+ | </noinclude> |
Revision as of 07:53, 7 October 2019
{{User:Sub4rctic/Woods}}
List of all woods with < and > as PREFIX and SUFFIX, semicolon separated
{{#replace:string|search term|replacement term}}
replacement syntax
{{#replace:{{User:Sub4rctic/Woods}}|search term|replacement term}}
use the woods template as the string
{{#replace:{{User:Sub4rctic/Woods}}|>|<nowiki/> <nowiki/>SUFFIX}}
If a space is used in the replacement term, must be nowiki'd out with self-closing tags
{{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX}}|<|PREFIX}}
nest SUFFIX replacement inside a PREFIX replacement
{{#explode:string|delimiter|position|limit}}
explode syntax. Pos counted from 0
{{#explode:{{{1}}}|,|0}}
Returns before comma
{{#explode:{{{1}}}|,|1}}
returns string after comma
{{#replace:{{#replace:{{User:Sub4rctic/Woods}}|>|SUFFIX,{{#explode:{{{1}}}|,|1}}}}|<|PREFIX}}
after the suffix add a comma and add param 1 string after comma. Problem: leaves a comma even when there is no ",#" after item name.
{{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }}
if syntax
{{#if: {{#explode:{{{1}}}|,|1}}|,{{#explode:{{{1}}}|,|1}}|}}
if param 1 string after comma delimiter is not empty, return ", string", and if it is, return nothing
{{#replace: {{#replace: {{User:Sub4rctic/Woods}}|>|SUFFIX{{#if:{{#explode:{{{1}}}|,|1}}|,{{#explode:{{{1}}}|,|1}}|}}}}|<|PREFIX}}
so if param 1 has a comma then number, a comma and the number will be placed after SUFFIX. If not, then nothing will be placed after SUFFIX
{{#switch: comparison string | case = result | case = result | #default = default result }}
Switch syntax