1

I am trying to use a backbone template to render a table with a model object. while rendering the table i have to create a table column depending upon the model property. i tried doing

<script id="table-rows" type="text/template">
<td> <span class="status"> {{ status }} </span> </td>
<% if (status == 'completed') { %>
<td>
something
</td>
<% } %>
</script>

my view for single row am calling the render method like

render: function () {
this.$el.html(this.template(this.model.toJSON()));
return this;
}

but this is rendering the column always even the condition is not matching. Let me know where am going wrong. Thanks

user3625533
  • 339
  • 1
  • 4
  • 20

1 Answers1

1

Why not try this:

<% if ('{{status}}' == 'completed') { %>
<td>
something
</td>
<%}%>
Jim Edelstein
  • 792
  • 6
  • 10