Line breaks

257 views
Skip to first unread message

Tobi

unread,
Sep 28, 2011, 9:35:12 AM9/28/11
to dotl...@googlegroups.com
Hi!

I'm thinking about using DotLiquid for rendering some plain text files.

How exactly are line breaks handled?

If I do this:

--- SNIP ---
xxx
{% if false %}
{% endif %}
yyy
--- SNIP ---

I get:

--- SNIP ---
xxx

yyy
--- SNIP ---

...but I would expect to get no empty line between "xxx" and "yyy".
And it gets even worse in this case:

--- SNIP ---
xxx
{% if true %}
--------------
{% endif %}
yyy
--- SNIP ---

becomes:

--- SNIP ---
xxx

--------------

yyy
--- SNIP ---

(Snippets are only indented in this posting)

Tobias

Tim Jones

unread,
Sep 28, 2011, 11:42:30 AM9/28/11
to dotl...@googlegroups.com
Hi Tobias,

You can put a hyphen before the end of each tag, and that will suppress the line breaks that would normally be there:

<ul>
{% for item in user.tasks -%}
  <li>{{ item.name }}</li>
{% endfor -%}
</ul>

Incidentally, that example is from the Try Online page of our website, so you can test it out for yourself there.

Hope that helps,
Tim

Tobi

unread,
Sep 28, 2011, 12:46:02 PM9/28/11
to dotl...@googlegroups.com
Am 28.09.2011 17:42, schrieb Tim Jones:

> You can put a hyphen before the end of each tag, and that will suppress the
> line breaks that would normally be there:

> Hope that helps,

It did. Thanks a lot!

> Incidentally, that example is from the Try Online

Looks like this is the only reference to the usage of the hyphen. I
couldn't find it anywhere else in the docs.

I wanted to add it to the Wiki, but this belongs to the Ruby version of
Liquid which doesn't seem to support the hyphen.

Tobias

Tim Jones

unread,
Sep 29, 2011, 12:53:17 PM9/29/11
to dotl...@googlegroups.com
Hi Tobi,

Great, glad it works.

I have amended the "DotLiquid for Designers" page to include a section that describes any differences between DotLiquid and Liquid template syntax. As the first item for that section, I have added a note about line breaks.


Best wishes,
Tim
Reply all
Reply to author
Forward
0 new messages