samvincent / jekyll-haml

HAML html converter for Jekyll
MIT License
88 stars 40 forks source link

if statements? #9

Closed chrishough closed 10 years ago

chrishough commented 10 years ago

How would you use if statements?

        | {% if page.tags %}
            meta[name="keywords" content="{{ page.tags | join: ', ' }}"]
        | {% endif %}
felixkiss commented 10 years ago

All Liquid commands should be handled like plain text (because it is processed after the Haml conversion.

So just don't indent after an (Liquid) if statement.

Consider the following example:

%ul
  {% if 1=0 %}
  %li= "Foo"
  {% else %}
  %li= "Bar"
  {% endif %}

For your code I would write:

| {% if page.tags %}
%meta{name: "keywords", content: "{{ page.tags | join: ', ' }}"}
| {% endif %}

Also possible:

= "| {% if page.tags %}"
%meta{name: "keywords", content: "{{ page.tags | join: ', ' }}"}
= "| {% endif %}"
chrishough commented 10 years ago

Thank you! :smile_cat:

schoenwaldnils commented 7 years ago

Is it possible to work around the indentation? I really don't like the look of the not indented liquid-tags.