Login

Snippets by esanchez

Snippet List

Inline truncate by character number

Sometimes I need to truncate a string after a number of characters, usually to avoid breaking the page layout. When the string we have to truncate is a filename I don't want to hide its extension so a user can easily recognize the file. My solution is add the ellipsis at the middle of the string converting `ALongLongLongTitleDocumentThatExemplifiesThisSnippet.txt` into `ALongLongLong...hisSnippet.txt`

  • filter
  • truncate
Read More

esanchez has posted 1 snippet.