You can write a simple function to do that, pure and straight javascript, like:
// Function that truncates string at the 10th char and appends '... (read more)'
// if the string has more than 10 chars
var ellipsize_special = function (string) {
if (string.length > 10) {
return string.substring(0,10) + "... (read more)";
} else {
return string;
}
}
Testing it:
var short_str = "apple";
var long_str = "pineapple juice";
ellipsize_special(short_str);
ellipsize_special(long_str);
Caveat: it is a simple method. Ellipsizing correctly would involve truncating the string at the first blank character before the char limit. Browsers have support to that (by means of CSS parameters), but they do not add the "read more" string that you wanted, and it is a mess trying to make that work properly, at least the last time I tried, in Opera, Firefox, Chrome, IE...