Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I lowercase a field using Handlebars.js?

I want to do something like this:

{{user.name.toLowerCase()}} 

but I get this error:

Error: Parse error on line X: ...tatus {{user.name.toLowerCase()}}">   -----------------------^ Expecting 'ID', got 'undefined' 
like image 238
Eric the Red Avatar asked Jan 25 '12 22:01

Eric the Red


People also ask

How do you lowercase a variable in JavaScript?

JavaScript String toLowerCase() The toLowerCase() method converts a string to lowercase letters. The toLowerCase() method does not change the original string.


1 Answers

As simply explained in the doc :

Handlebars.registerHelper('toLowerCase', function(str) {   return str.toLowerCase(); }); 

And just use it like this :

<h1>By {{toLowerCase author}}</h1> 
like image 114
Cyril N. Avatar answered Oct 23 '22 00:10

Cyril N.