Шаблон:Strloc insert
{{#ifeq:-92|-92x
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 5 <= 0|{{{1}}}{{{2}}}|{{{2}}}{{safesubst:#ifexpr: {{#expr:5-1 }} < 0
|{{{1 }}}
|{{safesubst:#ifexpr: {{#expr:5-1 }} +1 > 8 | |
{{{1 }}} }}
}}}}
{{#ifeq:strloc insert |док
|
{{#ifeq:show |show
|| Ово је документациона подстраница за Шаблон:Strloc insert. Садржи информације о коришћењу, категоријама и другом садржају који није део оригиналне странице. |
}}{{#if: |
| {{#ifexist:Шаблон:Strloc insert
| [[Категорија:Документација {{#switch:Шаблон |Шаблон=шаблона |Модул=модула |Корисник=корисничких страница |#default=Википедије}}]]
|
}}
}}
|
}}
The string-inserter Template:Strloc_insert inserts a string into another string at a specified location, or appends it at the end.
Usage
- {{Strloc insert|<string1>|strloc=<n>|<string2>}}
Returns string1 with string2 inserted at location strloc=n, where n=1 denotes the start of the string (prepending). If strloc <= 0 then string2 is appended at the end of string1. The parameter strloc can be a math formula, such as: strloc={{{len}}}-2, or strloc=abs(-2*5)+6.
Examples
The following show various uses:
- {{Strloc insert|abcdef|strloc=4|ZZZ}}
→ {{#ifeq:4|-92
- {{Strloc insert|abcdef|strloc=4|ZZZ}}
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 4 <= 0|abcdefZZZ|ZZZ{{safesubst:#ifexpr: {{#expr:4-1 }} < 0
|abcdef
|{{safesubst:#ifexpr: {{#expr:4-1 }} +1 > 6 | |
abcdef }}
}}}}
- {{Strloc insert|123456|strloc=1|++}}
→ {{#ifeq:1|-92
- {{Strloc insert|123456|strloc=1|++}}
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 1 <= 0|123456++|++{{safesubst:#ifexpr: {{#expr:1-1 }} < 0
|123456
|{{safesubst:#ifexpr: {{#expr:1-1 }} +1 > 6 | |
123456 }}
}}}}
- {{Strloc insert|Abcd|strloc=0 |EFG}}
→ {{#ifeq:0|-92
- {{Strloc insert|Abcd|strloc=0 |EFG}}
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 0 <= 0|AbcdEFG|EFG{{safesubst:#ifexpr: {{#expr:0-1 }} < 0
|Abcd
|{{safesubst:#ifexpr: {{#expr:0-1 }} +1 > 4 | |
Abcd }}
}}}}
- {{Strloc insert|<i>Out of Africa (film)|strloc=17|</i>}} → {{#ifeq:17|-92
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 17 <= 0|Out of Africa (film)|{{safesubst:#ifexpr: {{#expr:17-1 }} < 0
|Out of Africa (film)
|{{safesubst:#ifexpr: {{#expr:17-1 }} +1 > 23 | |
Out of Africa (film) }}
}}}}
- {{Strloc insert|[[Out of Africa (film)|<i>Out of Africa (film)]]|strloc=17+20|</i>}} → {{#ifeq:17+20|-92
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 17+20 <= 0|Out of Africa (film)|{{safesubst:#ifexpr: {{#expr:17+20-1 }} < 0
|Out of Africa (film)
|{{safesubst:#ifexpr: {{#expr:17+20-1 }} +1 > 48 | |
Out of Africa (film) }}
}}}}
- Note, the example wikilinking "Out of Africa" inserted "</i>" as end-italics,
but with strloc=17+20 to skip farther in the "[[ ]]" wikilink string.
- {{Strloc insert|<i>Cosmos (book)|strloc={{strfind_short|Cosmos (book)|(|1}}|</i>}} → {{#ifeq:8|-92
- Note, the example wikilinking "Out of Africa" inserted "</i>" as end-italics,
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 8 <= 0|Cosmos (book)|{{safesubst:#ifexpr: {{#expr:8-1 }} < 0
|Cosmos (book)
|{{safesubst:#ifexpr: {{#expr:8-1 }} +1 > 16 | |
Cosmos (book) }}
}}}}
- In the example with "Cosmos (book)" the number for strloc was set by finding "(" in the
title. If there had been no "(" then the result would append "</i>" at the end of the title.
- In the example with "Cosmos (book)" the number for strloc was set by finding "(" in the
Limitations
The text at the end (after string2) is subject to the limitations of Template:Str_right. Spaces around the inserted string are limited to 1 space, before or after:
- {{Strloc insert|[[J. Oppenheimer]]|strloc=6 |Robert }} → {{#ifeq:6|-92
|
ГРЕШКА {Strloc_insert} — Очекивано strloc=n, али није пронађено.
}}{{#ifexpr: 6 <= 0|J. OppenheimerRobert |Robert {{safesubst:#ifexpr: {{#expr:6-1 }} < 0
|J. Oppenheimer
|{{safesubst:#ifexpr: {{#expr:6-1 }} +1 > 18 | |
J. Oppenheimer }}
}}}}
Spaces beyond the inserted string might be encoded as " " rather than being real spaces.
See also