Gets a Shortened version of a string
Namespace:
AdvantageCMS.Core.Common
Assembly:
AdvantageCMS.Core (in AdvantageCMS.Core.dll)
Parameters
- text
- Type: String
The text.
- length
- Type: Int32
The length.
- truncateWords
- Type: Boolean
if set to true [truncate words].
- isShorter
- Type: Boolean%
indicates if the text returned is shorter than the original text
Return Value
return string of shortened text
if we want to trucate words
if text needs shortening, shorten the text at the exact length given
if the text does not need shortening, return the text as is
if we do not want to trucate any words
split text into an array of words
loop through all words
if the new return value will be longer than the allowed value
don't append anymore words
append the new word to the return value and a space
get trimmed version of return value
if the values length is les than the allowed length
return original value
if the values length is not less than the allowed length
return shortened value