diff --git a/src/lang/string.js b/src/lang/string.js index cf5bdec0e..67e1e27c5 100644 --- a/src/lang/string.js +++ b/src/lang/string.js @@ -202,6 +202,20 @@ Object.extend(String.prototype, (function() { * * Truncates a string to given `length` and appends `suffix` to it (indicating * that it is only an excerpt). + * + * ##### Examples + * + * 'A random sentence whose length exceeds 30 characters.'.truncate(); + * // -> 'A random sentence whose len...' + * + * 'Some random text'.truncate(); + * // -> 'Some random text.' + * + * 'Some random text'.truncate(10); + * // -> 'Some ra...' + * + * 'Some random text'.truncate(10, ' [...]'); + * // -> 'Some [...]' **/ function truncate(length, truncation) { length = length || 30; @@ -214,6 +228,11 @@ Object.extend(String.prototype, (function() { * String#strip() -> String * * Strips all leading and trailing whitespace from a string. + * + * ##### Example + * + * ' hello world! '.strip(); + * // -> 'hello world!' **/ function strip() { return this.replace(/^\s+/, '').replace(/\s+$/, ''); @@ -366,10 +385,15 @@ Object.extend(String.prototype, (function() { return this.extractScripts().map(function(script) { return eval(script) }); } - /** + /** related to: String#unescapeHTML * String#escapeHTML() -> String * * Converts HTML special characters to their entity equivalents. + * + * ##### Example + * + * '