[gf_lowtext]

Description

Link: [gf_lowtext]
Author: Gaetano Frascolla
Category: String
Version: 8.x
License: Public Domain
Posted: Jul. 14, 2006
Updated: Jul. 14, 2006
More by this author...
Based on [string_truncate] tag created by John Burwell, gf_lowtext returns truncated text to specified chars without truncate words, and add a suffix at the end of the string. It takes three params: an input -text, the lenght of the output and an optional suffix for the output. If the result ends with truncated word, this tag will remove the remaining chars, and will return a clean string.

Parameters

-chars integer, required The length of the output string
-suffix string, optional A string to append at the end
-text string, required The text to be truncated

Sample Usage

[gf_lowtext: -text=($text), -chars=40, -suffix='...']

example:

gf_lowtext:
-text='Click the "Download" button below to retrieve a copy of this tag',
-chars=40,
-suffix='...'

Only truncate:

Click the "Download" button below to retr...

Truncate and Clean

Click the "Download" button below to...
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Define_Tag: 'gf_lowtext',
-required='text',
-required='chars',
-optional='suffix',
-description='Return text truncated to specified chars without truncate words';


Local:'long_text'=(String:(#text));
Local:'chars_lenght'=(Integer:(#chars));
Local:'text_suffix'=(String:(#suffix));

if: #long_text->(Size) > (#chars_lenght);

Local:'new_text'=(#long_text)->(Substring: 1, (#chars_lenght));


While:(string_endswith:(#new_text), -find=' ')=='false';

Local:'chars_lenght'=(#chars_lenght)-1;

Local:'new_text'=(#long_text)->(Substring: 1, (#chars_lenght));

/while;

Local:'chars_lenght'=(#chars_lenght)-1;

Local:'new_text'=(#long_text)->(Substring: 1, (#chars_lenght));


Local:'new_text'	= (#new_text) + (#text_suffix);

return:(#new_text);

else;

return:(#long_text);

/if;


/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular