Changes
m
Updated transclusion of navbox.
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES & INTERWIKIS AT BOTTOM OF THIS PAGE -->
The string-inserter '''[[Template:Strloc_insert]]''' inserts a string into another string at a specified location, or appends it at the end.
__NOTOC__
=== 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}}{{pad|2em}}→ {{Strloc insert|abcdef|strloc=4|ZZZ}}
:* {{Strloc insert|123456|strloc=1|++}}{{pad|2em}}→ {{Strloc insert|123456|strloc=1|++}}
:* {{Strloc insert|Abcd|strloc=0 |EFG}}{{pad|2em}}→ {{Strloc insert|Abcd|strloc=0|EFG}}
:* <nowiki>{{Strloc insert|<i>Out of Africa (film)|strloc=17|</i>}}</nowiki> → {{Strloc insert|<i>Out of Africa (film)|strloc=17|</i>}}
:* <nowiki>{{Strloc insert|[[Out of Africa (film)|<i>Out of Africa (film)]]|strloc=17+20|</i>}}</nowiki> → {{Strloc insert|[[Out of Africa (film)|<i>Out of Africa (film)]]|strloc=17+20|</i>}}
:: Note, the example wikilinking "Out of Africa" inserted "</i>" as end-italics,<br>but with strloc=17+20 to skip farther in the <nowiki>"[[ ]]"</nowiki> wikilink string.
:* <nowiki>{{Strloc insert|<i>Cosmos (book)|strloc={{strfind_short|Cosmos (book)|(|1}}|</i>}}</nowiki> → {{Strloc insert|<i>Cosmos (book)|strloc={{strfind_short|Cosmos (book)|(|1}}|</i>}}
:: In the example with "[[Cosmos (book)]]" the number for strloc was set by finding "(" in the<br>title. If there had been no "(" then the result would append "</i>" at the end of the title.
===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:
:* <nowiki>{{Strloc insert|[[J. Oppenheimer]]|strloc=6 |Robert }}</nowiki> → {{Strloc insert|[[J. Oppenheimer]]|strloc=6 |Robert }}
Spaces beyond the inserted string might be encoded as "&#32;" rather than being real spaces.
=== See also ===
{{string-handling templates}}
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:String manipulation templates]]
</includeonly>
<!-- PLEASE ADD CATEGORIES & INTERWIKIS AT BOTTOM OF THIS PAGE -->
The string-inserter '''[[Template:Strloc_insert]]''' inserts a string into another string at a specified location, or appends it at the end.
__NOTOC__
=== 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}}{{pad|2em}}→ {{Strloc insert|abcdef|strloc=4|ZZZ}}
:* {{Strloc insert|123456|strloc=1|++}}{{pad|2em}}→ {{Strloc insert|123456|strloc=1|++}}
:* {{Strloc insert|Abcd|strloc=0 |EFG}}{{pad|2em}}→ {{Strloc insert|Abcd|strloc=0|EFG}}
:* <nowiki>{{Strloc insert|<i>Out of Africa (film)|strloc=17|</i>}}</nowiki> → {{Strloc insert|<i>Out of Africa (film)|strloc=17|</i>}}
:* <nowiki>{{Strloc insert|[[Out of Africa (film)|<i>Out of Africa (film)]]|strloc=17+20|</i>}}</nowiki> → {{Strloc insert|[[Out of Africa (film)|<i>Out of Africa (film)]]|strloc=17+20|</i>}}
:: Note, the example wikilinking "Out of Africa" inserted "</i>" as end-italics,<br>but with strloc=17+20 to skip farther in the <nowiki>"[[ ]]"</nowiki> wikilink string.
:* <nowiki>{{Strloc insert|<i>Cosmos (book)|strloc={{strfind_short|Cosmos (book)|(|1}}|</i>}}</nowiki> → {{Strloc insert|<i>Cosmos (book)|strloc={{strfind_short|Cosmos (book)|(|1}}|</i>}}
:: In the example with "[[Cosmos (book)]]" the number for strloc was set by finding "(" in the<br>title. If there had been no "(" then the result would append "</i>" at the end of the title.
===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:
:* <nowiki>{{Strloc insert|[[J. Oppenheimer]]|strloc=6 |Robert }}</nowiki> → {{Strloc insert|[[J. Oppenheimer]]|strloc=6 |Robert }}
Spaces beyond the inserted string might be encoded as "&#32;" rather than being real spaces.
=== See also ===
{{string-handling templates}}
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:String manipulation templates]]
</includeonly>