How to use the Utils function from handlebars

Find comprehensive JavaScript handlebars.Utils code examples handpicked from public code repositorys.

54
55
56
57
58
59
60
61
62
// Handlebars.registerHelper('formatdate', function(text) {
// 	return new Handlebars.SafeString(text.slice(0,7));
// });

Handlebars.registerHelper('breaklines', function(text) {
	text = Handlebars.Utils.escapeExpression(text);
	text = text.replace(/(\r\n|\n|\r)/gm, '<br>');
	return new Handlebars.SafeString(text);
});
fork icon1
star icon0
watch icon0

322
323
324
325
326
327
328
329
330
331
332
333
  }
}


Handlebars.registerHelper('link', function(text, url) {
  text = Handlebars.Utils.escapeExpression(text);
  url = Handlebars.Utils.escapeExpression(url);
  var result = '<a href="' + url + '">' + text + '</a>';


  return new Handlebars.SafeString(result);
});
fork icon0
star icon0
watch icon1

+ 3 other calls in file