Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Str left/doc: Difference between revisions

Template page
mNo edit summary
Update.
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
This template returns a certain number of characters from the start of a text string.


=== Usage ===
=== Usage ===


*'''first parameter''' ''(compulsory)'' the text string to truncate
<nowiki>{{Str left|<string>|<count>}}</nowiki>
*'''second parameter''' the number of characters to return. If invalid or empty, an empty string is returned. If undefined, it defaults to 1.
 
Gives the <count> characters from the start of the string.
 
If <count> is invalid or empty, an empty string is returned. If undefined, it defaults to 1.
 
=== Examples ===


===Examples===
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 10 }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 10 }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 1 }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 1 }}
Line 16: Line 19:


=== See also ===
=== See also ===
Equivalent to [[Template:Trunc]].  One is superior to the other - which?
* {{Tl|Trunc}} - which is almost identical.
* {{Tl|Str right}}
* {{Tl|Str rightc}}


<includeonly>
<includeonly>

Revision as of 23:21, 7 October 2009

Usage

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

Gives the <count> characters from the start of the string.

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

Examples

  • {{Str left| lorem ipsum dolor sit amet | 10 }} → lorem ipsu
  • {{Str left| lorem ipsum dolor sit amet | 1 }} → l
  • {{Str left| lorem ipsum dolor sit amet | foo }}
  • {{Str left| lorem ipsum dolor sit amet | }}
  • {{Str left| lorem ipsum dolor sit amet }} → l

See also


Cookies help us deliver our services. By using our services, you agree to our use of cookies.