Created
July 15, 2018 23:23
-
-
Save iliyaZelenko/3219fb95081f2a2deffbdd779677df14 to your computer and use it in GitHub Desktop.
Vue truncate filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.filter('truncate', (text, stop = 15, clamp) => { | |
if (!text) { | |
return text | |
} | |
return text.slice(0, stop) + (stop < text.length ? clamp || '...' : '') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment