Skip to content

Instantly share code, notes, and snippets.

@mmourafiq
Created July 11, 2013 14:31
Show Gist options
  • Save mmourafiq/5975972 to your computer and use it in GitHub Desktop.
Save mmourafiq/5975972 to your computer and use it in GitHub Desktop.
Blog.filter('truncate', function () {
return function (text, length, end) {
if (isNaN(length))
length = 10;
if (end === undefined)
end = "...";
if (text.length <= length || text.length - end.length <= length) {
return text;
}
else {
return String(text).substring(0, length-end.length) + end;
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment