documentation for truncate fitler + only space between dots and words in wordwise mode.

This commit is contained in:
Niels Lyngsø
2019-05-09 14:38:13 +02:00
parent 4b55f99493
commit 9c599868cc

View File

@@ -1,3 +1,15 @@
/**
* @ngdoc filter
* @name umbraco.filters.filter:truncate
* @namespace truncateFilter
*
* param {any} wordwise if true, the string will be cut after last fully displayed word.
* param {any} max max length of the outputtet string
* param {any} tail option tail, defaults to: ' ...'
*
* @description
* Limits the length of a string, if a cut happens only the string will be appended with three dots to indicate that more is available.
*/
angular.module("umbraco.filters").filter('truncate',
function () {
return function (value, wordwise, max, tail) {
@@ -13,7 +25,7 @@ angular.module("umbraco.filters").filter('truncate',
value = value.substr(0, lastspace);
}
}
return value + (tail || ' …');
return value + (tail || (wordwise ? ' …' : '…'));
};
}
);