Skip to content

Instantly share code, notes, and snippets.

@iliyaZelenko
Created July 15, 2018 23:23
Show Gist options
  • Save iliyaZelenko/3219fb95081f2a2deffbdd779677df14 to your computer and use it in GitHub Desktop.
Save iliyaZelenko/3219fb95081f2a2deffbdd779677df14 to your computer and use it in GitHub Desktop.
Vue truncate filter
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