0

I'm developing an HTML email on Sailthru and was wondering if there is a way to truncate a long item title? If it is past 15 characters, to show the first 15 characters and then add an ellipsis?

I've looked at the developer's handbook and could not find anything on this. Let me know where and if I can find any information on this.

What I have it currently this

{if  length(item.title) < 15}{item.title}{/if}
{if  length(item.title) > 15}{item.title=slice(content, 0, 14)}{/if}

2 Answers2

0

The way to make this work in an email is to figure out the maximum length of the title and set that as your max-width. Any overflow beyond that point will be replaced by an elipsis. It's not very elegant because you can't get it to break gracefully at the end of a word, but this works with most email clients.

.title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 200px;
}

Example:

You can make this method work with character count if you can determine your font, write out 123456789012345, determine your max-width for 15 characters and you're set.

Good luck with long names.

gwally
  • 3,349
  • 2
  • 14
  • 28
0

Here's how to use Sailthru Zephyr code to limit a string to its first 15 characters, and then add an ellipsis:

{if length(item.title) < 15}{item.title}{else}{substr(item.title, 0, 15)}...{/if}