ep.scrunch()
Categories: Utilities
ep.scrunch( string, [ length ] )
Plugin: ep.core
Description: Trim the length of a text.
-
ep.scrunch( string, [ length ] )
version added: 6.11.0string A string to scrunch.
length A number to set the length of chars for the scrunch result. Default is 30.
-
ep.scrunch( string, [ options ] )
version added: 6.11.0string A string to scrunch.
length A set of key/value pairs that configure the scrunch.
The ep.scrunch()
method trim the length of a text in different modes.
With the ratio argument you can set the trim position, so you can trim the begin, end or middle of a text. The trimmed text will replacer with a specified spacer.
-
Scrunch a text at the end.
Code:
ep.scrunch("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor.")
Results:
Lorem ipsum dolor sit amet,...
-
Scrunch a text at the begin.
Code:
ep.scrunch( "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor.", { ration: 0 })
Results:
...diam nonumy eirmod tempor.
-
Scrunch a text at the middle to length 50 without cut a word.
Code:
ep.scrunch( "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor.", { ration: 0, cut: false, spacer: "....." });
Results:
Lorem ipsum dolor sit ..... nonumy eirmod tempor.