Sha256: 1db06e082f4d89ce7dcdd37952ceb4850477496b617b8e39236d562a58486244
Contents?: true
Size: 732 Bytes
Versions: 10
Compression:
Stored size: 732 Bytes
Contents
# Usage: # {{some_text | truncate:100:'...':true}} # # Options: # max (integer) - max length of the text, cut to this number of chars, # tail (string, default: ' …') - add this string to the input string if the string was cut. # wordwise (boolean) - if true, cut only by words bounds, angular.module("maestrano.filters.truncate",[]).filter("truncate", -> (value, max, tail,wordwise) -> return "" unless value max = parseInt(max, 10) return value unless max return value if value.length <= max value = value.substr(0, max) if wordwise lastspace = value.lastIndexOf(" ") value = value.substr(0, lastspace) unless lastspace is -1 return value + (tail or "…") )
Version data entries
10 entries across 10 versions & 1 rubygems