Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

JavaScriptMVC to CanJS EJS differences

$
0
0
I am looking to move my application from JavaScriptMVC to CanJS and am noticing some issues with EJS templates I had written previously that worked in JMVC but not in CanJS.  Are there any specific guidelines for writing templates?  For instance I thought the following would work 

For instance this worked in JavaScriptMVC 

  1. <% for(var i = grouped.length - 1; i >= 0; i--){ 
  2. var facetGroup = grouped[i];
  3. for(var j = facetGroup.length - 1; j >= 0; j--){ %>
  4. <a href=""><%== facetGroup[j].label %></a>
  5. <% if(j != 0){
  6. %> or  <%
  7. }
  8. }
  9. if(i != 0){
  10. %> > <%
  11. }
  12. }
but had to be reformatted as follows to work in CanJS
  1. <% for(var i = grouped.length - 1; i >= 0; i--){ 
  2. var facetGroup = grouped[i];
  3. for(var j = facetGroup.length - 1; j >= 0; j--){ %>
  4. <a href=""><%== facetGroup[j].label %></a>
  5. <% if(j != 0){ %> 
  6. or 
  7. <% } %>
  8. <% }
  9. if(i != 0){ %>
  10. >
  11. <% } %>
  12. <% } %>

While this seems to be a subtle difference I really do not understand why this was required.  Also what is the best way of debugging templates?  I get cryptic errors like "Uncaught SyntaxError: Unexpected token if", how do others track down issues when dealing with templates that have a bit of logic in it?

Viewing all articles
Browse latest Browse all 3491

Trending Articles