Name: truncate
Owner: Center for Open Science
Description: Dead simple HTML-safe truncation via the DOM.
Created: 2016-07-22 18:27:01.0
Updated: 2016-07-22 18:27:02.0
Pushed: 2016-04-14 14:14:10.0
Size: 209
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
uery.truncate('<p>Stuff and <i>Nonsense</i></p>', {
ngth: 13
Stuff and <i>No?</i></p>'
uery('<p>Stuff and <i>Nonsense</i></p>').truncate({
ngth: 13
tml();
Stuff and <i>No?</i></p>'
Default options are stored on jQuery.truncate.defaults
.
Default: Infinity
The maximum length (including the ellipsis) of the truncated html.
Default: false
If stripTags
is truthy all html tags will be stripped, leaving only the text.
uery.truncate('<p>Stuff and <i>Nonsense</i></p>', {
ngth: 13,
ripTags: true
ff and No?'
Default: false
If words
is truthy the input will only be truncated at word boundaries.
uery.truncate('<p>Stuff and <i>Nonsense</i></p>', {
ngth: 13,
rds: true
Stuff and?</p>'
Default: false
When words
and keepFirstWord
are both truthy the input will contain
at least one word beside the ellipsis even if it's longer than
a target length.
uery.truncate('<p>Stuff and <i>Nonsense</i></p>', {
ngth: 4,
rds: true,
epFirstWord: true
Stuff?</p>'
Default: false
If noBreaks
is truthy the input will contain no break elements.
uery.truncate('<p>Stuff and<br><i>Nonsense</i></p>', {
ngth: 13,
Breaks: true
Stuff and <i>No?</i></p>'
Default: '?'
The ellipsis
setting is used to provide a different character for the ellipsis.
uery.truncate('<p>Stuff and <i>Nonsense</i></p>', {
ngth: 13,
lipsis: '~'
Stuff and <i>No~</i></p>'