Guig
Guig

Reputation: 10187

Underscore template not rendering variable with <%-

I have a simple template:

<div class='welcome'>Welcome <%- first_name %>!</div>

However my variable first_name is not rendered. This works fine:

<div class='welcome'>Welcome <%= first_name %>!</div>

and this correctly logs the variable:

<div class='welcome'>Welcome <%- first_name %><% console.log(first_name);console.log(typeof(first_name)); %>!</div>

which is of type string as expected. I couldn't find anyone with the same problem in the community. Is there something obvious I'm missing?

For context, this is used in a Marionette app that takes care of displaying the template.

Upvotes: 2

Views: 160

Answers (1)

Guig
Guig

Reputation: 10187

This is an issue related to requirejs-tpl. Here is a discussion of the issue

dawsontoth made a fix in his fork

To add it to your bower dependencies, add "requirejs-tpl-dawsontoth": "*", (it also depends on requirejs-text)

Upvotes: 2

Related Questions