mattmccray / liquid.js

JavaScript port of Tobias Luetke's Liquid template engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extraneous Commas

dhcole opened this issue · comments

@darthapo I know you fixed a comma related bug a while ago, so I'm hoping you may have some insight into a weird issue I'm seeing now.

This only happens sometimes, and I can't seem to track down why.

Basically every tag is insetting a comma into the output. Here's an example:

screen shot 2013-06-26 at 12 18 11 pm

And here's the template code for this example:

    {% if page.notice %}
    <div class='notice pad2'>
      <h3><span class='icon alert'></span>{{page.notice.title}}</h3>
      {{page.notice.message | markdownify}}
    </div>
    {% endif %}

    <h1>{{page.title}}</h1>

    <div class="blog-info">

      <span class="blog-date">{{page.date | date:"%B %d %Y"}}</span>
      {% if author.hidden %}
      <span class="blog-author">By <a href='https://twitter.com/{{author.twitter}}'>{{author.title}}</a></span>
      {% else %}
       <span class="blog-author">By <a href='{{site.baseurl}}/about/team/#{{author.title|downcase|replace:' ','-'}}'>{{author.title}}</a></span>
      {% endif %}

Do you have any suggestions on what might be the cause or how I can work around this issue?

It looks like this has to do with the content being enclosed in a unless tag. Here's a full test case:

Ok, here's the problem: https://github.com/darthapo/liquid.js/blob/master/source/default_tags.js#L453

It should be return [output].flatten().join('');.

I'll open a pull request.

Closed by #22