Wikisage, the free encyclopedia of the second generation, is digital heritage

Template:Str left: Difference between revisions

From Wikisage
Jump to navigation Jump to search
(https://en.wikipedia.org/w/index.php?title=Template:Str_left&oldid=741880261)
 
(cat)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<includeonly>{{safesubst:padleft:|{{{2|1}}}|{{{1}}}}}</includeonly><noinclude>
<includeonly>{{safesubst:padleft:|{{{2|1}}}|{{{1}}}}}</includeonly><noinclude>
{{documentation}}
{{templateinfo|1=
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
;Purpose
This template removes leading whitespace from a string and then trims it at the end.
 
;Use
<nowiki>{{Str left|<string>|<count>}}</nowiki>
 
Gives the resultant <count> of characters creating a substring of characters from the start of the trimmed string (i.e. the substring returned will have length <count>, exclusive of leading whitespace characters, which are trimmed first before <count> is invoked).
 
If <count> is invalid, empty or zero, an empty string is returned. If undefined, it defaults to 1.
 
Note: only 500 characters can be extracted even if the <string> is longer. The maximum substring stops at 500 long, but gives no error message.
 
;Example
<nowiki>{{ Str left | &nbsp;&nbsp;&nbsp; Lorem ipsum dolor sit amet | 10 }}</nowiki> → Lorem ipsu}}
[[Category:Wikisage:Template:Auxiliary]]
</noinclude>
</noinclude>

Latest revision as of 22:50, 1 February 2017

Template description
Purpose

This template removes leading whitespace from a string and then trims it at the end.

Use

{{Str left|<string>|<count>}}

Gives the resultant <count> of characters creating a substring of characters from the start of the trimmed string (i.e. the substring returned will have length <count>, exclusive of leading whitespace characters, which are trimmed first before <count> is invoked).

If <count> is invalid, empty or zero, an empty string is returned. If undefined, it defaults to 1.

Note: only 500 characters can be extracted even if the <string> is longer. The maximum substring stops at 500 long, but gives no error message.

Example

{{ Str left |     Lorem ipsum dolor sit amet | 10 }} → Lorem ipsu