Reputation: 1249
I'm using the _.template
Lodash function and wanna know how to customize data values passed to it. I just wanna make something like (see toUpperCase()):
var compiled = _.template('hello ${ user.toUpperCase() } !');
compiled({ 'user': 'fred' });
Upvotes: 0
Views: 1738
Reputation: 7658
Format inline Javascript that has a return string like so:
hello <%= user.toUpperCase() %>
Note the =
after the <%
You can also run a block of code without necessarily outputting anything (though in this example I do inside the loop for kicks)
<%
for (var i = 0;i < 10;i++){
%>
Hello user # <%= i %>
Welcome.
<% } %>
Upvotes: 1