Reputation: 1
{{if inventory.title.length > 38}}
<p class="p1">
{{>(inventory.title.substring(0, 38) + '...').trim()}}
</p>
How do I correct this code to display in IE previous to IE9. I continue to get the following
Error: Object doesn't support property or method 'trim'.
Upvotes: 0
Views: 110
Reputation: 7452
Trim was not part of String till ECMAScript 5. IE9 is the first browser to support ECMAScript 5.
Though not recommended to modify the prototype of base classes,
if you wish you can add following lines of code for String.trim to work in all browsers.
if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
}
Upvotes: 1