show url in text fields

This commit is contained in:
Yuri Kuznetsov
2014-04-22 16:58:06 +03:00
parent 7fc5b0e16e
commit 2de6cebf23
2 changed files with 12 additions and 2 deletions
@@ -1 +1 @@
{{breaklines value}}
{{complexText value}}
+11 -1
View File
@@ -22,6 +22,8 @@
(function (Espo, _, Handlebars) {
Espo.ViewHelper = function (options) {
this.urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
this._registerHandlebarsHelpers();
}
@@ -38,7 +40,6 @@
language: null,
_registerHandlebarsHelpers: function () {
var self = this;
Handlebars.registerHelper('img', function (img) {
@@ -131,6 +132,15 @@
text = text.replace(/(\r\n|\n|\r)/gm, '<br>');
return new Handlebars.SafeString(text);
});
Handlebars.registerHelper('complexText', function (text) {
text = Handlebars.Utils.escapeExpression(text || '');
text = text.replace(/(\r\n|\n|\r)/gm, '<br>');
text = text.replace(self.urlRegex, function (url) {
return '<a href="' + url + '">' + url + '</a>';
});
return new Handlebars.SafeString(text);
});
Handlebars.registerHelper('translateOption', function (name, options) {
var scope = options.hash.scope || null;