1

how could i made it work?
underscore 1.8
the exception :
SyntaxError: expected expression, got ')'
any help will be apprecicate!

{{_.each(data,function(item){}}
<tr>
    <td>{{item.name}}</td>
    <td>{{item.gender}}</td>
    <td>{{item.age}}</td>
</tr>
 {{});}}

overcome some trouble,the code worked

_.templateSettings = {
      interpolate: /\{\{=(.+?)\}\}/g,
      evaluate: /\{\{(.+?)\}\}/g,
    };

the template

{{_.each(data,function(item){}}
<tr>
    <td>{{=item.name}}</td>
    <td>{{=item.gender}}</td>
    <td>{{=item.age}}</td>
</tr>
{{})}}

refrenced each loop in underscore.js template

Community
  • 1
  • 1
xcchcaptain
  • 113
  • 3
  • 14

1 Answers1

1

As per guidelines template setting should be updated for this. Would be great if you could share code with code pen example as code you posted not making a lot of sense.

_.templateSettings = {
  interpolate: /\{\{(.+?)\}\}/g
};

var template = _.template("Hello {{ name }}!");
template({name: "Mustache"});
=> "Hello Mustache!"
Anil Namde
  • 6,452
  • 11
  • 63
  • 100
  • thanks for your help,i have already got the templateSettings, got it work ,and ,in my condition ,also ,need the evalute setting! http://stackoverflow.com/questions/7361185/each-loop-in-underscore-js-template – xcchcaptain Apr 01 '16 at 07:11