0
votes

i have some problem with rending this jsrender code, it works if title == 'Teamledare Redo' but if i have more words like this: 'teamledare Redovisning', then it not works..

Why does it not render when there is more words ?

  <script id="oc_template" type="text/x-jsrender">

   <div class="node">

 {{if title == 'Teamledare Redovisning'}}
 <div><a href= {{>id}} >{{>title}}</a><br />{{>subtitle}}</div>
 {{else title == 'VD'}}
  <div><a href= {{>id}} >{{>title}}</a><br />{{>subtitle}}</div> 
  {{else}}
   <div><a href='#'>{{>title}}</a><br />{{>subtitle}}</div>
  {{/if}}

    </div>
1
i dont get any error, it just dont render - Anders
you mean like this?: <div><a href= "{{>id}} >{{>title}}"</a><br />{{>subtitle}}</div> - Anders
change {{else title == 'VD'}} to {{else if title == 'VD'}} - Deepak Ingole
I think you misunderstood my question, Its working already, Except if i have a title that is longer then 7-8 characters its not works - Anders
@Pilot No {{else if title == 'VD'}} is incorrect. - BorisMoore

1 Answers

0
votes

OK - buried in the comments above is the following:

The problem is that there is an error in the template. <a href= {{>id}} > should be <a href='{{>id}}'>.

As to {{if title == 'Teamledare Redovisning'}} that will work fine. Not an issue with JsRender at all.

BTW I would usually write the above as {{if title==='Teamledare Redovisning'}}. The extra white space you have makes it harder to parse - though it will work fine. Similarly I would write {{else title==='VD'}}.