Popularity
0.4
Stable
Activity
0.0
Stable
3
2
0

Description

smart_truncate is a simple Rails gem that truncates text like a human. Ever wanted to truncate some text till the Ntn character only to find a word or sentence was cut in half? SmartTruncate fixes that."

Monthly Downloads: 27
Programming language: Ruby
License: MIT License

SmartTruncate alternatives and similar gems

Based on the "Misc" category.
Alternatively, view SmartTruncate alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of SmartTruncate or a related project?

Add another 'Misc' Gem

README

SmartTruncate

smart_truncate is a simple Rails gem that truncates text like a human. Ever wanted to truncate some text till the Ntn character only to find a word or sentence was cut in half? SmartTruncate fixes that."

INSTALL

gem install smart_truncate

BASIC smart_truncate USE

# truncate by characters and it will end in a meaningful word
SmartTruncate.by_chars("I am a nice sentance… Previous sentence is not with a proper multicolon ending.",26,'!')
# => "I am a nice sentance… Previous!"

# truncate by sentence
SmartTruncate.by_sentences("I am a nice sentance ... Previous sentence is not with a proper multicolon ending.",1)
# => "I am a nice sentance ..."

# truncate mixed by both sentence and characters/words
SmartTruncate.by_mixed("I am a nice sentance. Previous sentence is with a proper multicolon ending.",2,10)
# => "I am a nice."
SmartTruncate.by_mixed("I am a nice sentance. Previous sentence is with a proper multicolon ending.",1,100)
# => "I am a nice sentance."

LICENSE

This project uses MIT-LICENSE.


*Note that all licence references and agreements mentioned in the SmartTruncate README section above are relevant to that project's source code only.