jsonjinja icon indicating copy to clipboard operation
jsonjinja copied to clipboard

Jinja "If" operators are not being rendered as valid Javascript

Open ozburo opened this issue 13 years ago • 1 comments

Howdy:

If I have a simple template/html file such as:

<ul>
  {% if page == "homepage" -%}
  <li><a class="active href="#">Home</a></li>
  {%- else -%}
  <li><a href="#">Home</a></li>
  {%- endif %}  
</ul>

The resulting Javscript is missing the == operator, like so:

    if (l_page_0"homepage") { 
      w("<li><a class="active href="#">Home</a></li>");
    } else {
      w("<li><a href="#">Home</a></li>");
    }

... when it should obviously be like so:

    if (l_page_0 == "homepage") { 
      w("<li><a class="active href="#">Home</a></li>");
    } else {
      w("<li><a href="#">Home</a></li>");
    }

I tried to grok the source and come up with a simple solution, but alas, no dice.

Hopefully I haven't messed something up on my end and this can be a simple fix?

Thanks for all you do!

ozburo avatar Aug 03 '12 07:08 ozburo

I have the exact same problem.

untitaker avatar Feb 13 '13 20:02 untitaker