common:cropText

This tag will crop a text sent in – very useful for cropping a long texts into short introductions showing only part of the text.

Parameters

Name Required Default Type Description
Parameters
id false   String If specified the result is stored in this variable – otherwise the cropped text will be written to the page directly.
text true   Object/String The text you wish to crop.
startIndex false 0 Object/String If stated the tag will remove all chars before this index.
maxLength false   Object/String If stated the tag will remove all chars after the specified number of chars.
suffix false "..." Object/String Will add the suffix after the cropped text to indicate that there are more text which was removed.
adjustForEntities false true Object/String If the text contains HTML-entities it will affect the string length – set to false if you do not wish the tag to account for this (not recommended).


ID-result variable contains: A String-object.

Examples

The following example crops the text and outputs it to the page.

<common:cropText id="croppedText" text="This is a text which we want to crop" maxLength="10"/>
The result would be "This is a text which..." (without the qutoes).
Below is an example of a more customized example where we use an existing variable as input instead and also state our own suffix.
<common:cropText id="croppedText" text="${myTextVar}" maxLength="20" suffix="&raquo;"/>
The result would be "This is a text which »" (without the qutoes). 



comments powered by Disqus