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
(Templateinfo instead of Documentation)
(cat)
 
Line 14: Line 14:


;Example
;Example
<nowiki>{{ Str left | &nbsp;&nbsp;&nbsp; Lorem ipsum dolor sit amet | 10 }}</nowiki> → Lorem ipsu
<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