2

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.

2
  • hum maybe requirejs-tpl which I use to load the template. I could not reproduce it in a jsfiddle... Here is my _.templateSettings {evaluate: /<%([\s\S]+?)%>/g, interpolate: /<%=([\s\S]+?)%>/g, escape: /<%-([\s\S]+?)%>/g} It seems to be the same than in underscore source code. Commented Feb 26, 2015 at 20:30
  • It was indeed an issue relater to requirejs-tpl. Thanks for pointing me to the right direction! Commented Feb 26, 2015 at 21:06

1 Answer 1

2

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.