This project is read-only.
Used to truncate a variable to a character length.

Optional parameters:

First - integer value indicating how many characters to truncate to. Default is 80.
Second - the text string that replaces the truncated text. Its length is included in the truncation length setting. Default is '...'
Third - boolean value indicating whether to truncate on a word boundary (false) or on exact character boundary (true). Default is false.
Fourth - boolean value indicating whether the truncation happens at the end of the string (false) or in the middle of the string (true). Default is false. Note that setting this value to true will ignore word boundaries.

{'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'|truncate}
{"Nine women can't make a baby in a month"|truncate:15}
{"Nine women can't make a baby in a month"|truncate:15:'-'}
{"Nine women can't make a baby in a month"|truncate:15:'...':true}
{"Nine women can't make a baby in a month"|truncate:20:'...':true:true}


Will output

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy...
Nine women...
Nine women-
Nine women c...
Nine wom... a month

Last edited Feb 17, 2010 at 12:32 PM by JacoPretorius, version 2

Comments

No comments yet.