diff --git a/src/messenger/webim/js/164/handlebars_helpers.js b/src/messenger/webim/js/164/handlebars_helpers.js index 367a8a8e..a1a55a95 100644 --- a/src/messenger/webim/js/164/handlebars_helpers.js +++ b/src/messenger/webim/js/164/handlebars_helpers.js @@ -5,5 +5,5 @@ Copyright (c) 2005-2011 Mibew Messenger Community License: http://mibew.org/license.php */ -Handlebars.registerHelper("apply",function(b,a){var c=b,e=/^[0-9A-z_]+$/,a=a.split(/\s*,\s*/),d;for(d in a)if(a.hasOwnProperty(d)&&e.test(a[d])){if("function"!=typeof Handlebars.helpers[a[d]])throw Error("Unregistered helper '"+a[d]+"'!");c=Handlebars.helpers[a[d]](c)}return new Handlebars.SafeString(c)}); +Handlebars.registerHelper("apply",function(b,a){var c=b,e=/^[0-9A-z_]+$/,a=a.split(/\s*,\s*/),d;for(d in a)if(a.hasOwnProperty(d)&&e.test(a[d])){if("function"!=typeof Handlebars.helpers[a[d]])throw Error("Unregistered helper '"+a[d]+"'!");c=Handlebars.helpers[a[d]](c).toString()}return new Handlebars.SafeString(c)}); Handlebars.registerHelper("formatTime",function(b){var a=new Date(1E3*b),b=a.getHours().toString(),c=a.getMinutes().toString(),a=a.getSeconds().toString();return(10$1'))});Handlebars.registerHelper("nl2br",function(b){return new Handlebars.SafeString(b.replace(/\n/g,"
"))}); \ No newline at end of file diff --git a/src/messenger/webim/js/source/handlebars_helpers.js b/src/messenger/webim/js/source/handlebars_helpers.js index 39a9753c..2936b79e 100644 --- a/src/messenger/webim/js/source/handlebars_helpers.js +++ b/src/messenger/webim/js/source/handlebars_helpers.js @@ -11,11 +11,19 @@ * * This helper provide an ability to apply several helpers to single Handlebars * expression + * + * Example of helper usage: + * + * {{apply text "emHelper, strongHelper"}} + * + * In the example above helpers will apply to text one after another: first + * 'emHelper' and second 'strongHelper'. */ Handlebars.registerHelper('apply', function(text, helpers) { var result = text; var validHelperName = /^[0-9A-z_]+$/; helpers = helpers.split(/\s*,\s*/); + // Apply helpers one after another for (var prop in helpers) { if (! helpers.hasOwnProperty(prop) || ! validHelperName.test(helpers[prop])) { @@ -26,7 +34,7 @@ Handlebars.registerHelper('apply', function(text, helpers) { "Unregistered helper '" + helpers[prop] + "'!" ); } - result = Handlebars.helpers[helpers[prop]](result); + result = Handlebars.helpers[helpers[prop]](result).toString(); } return new Handlebars.SafeString(result); });