samvincent / jekyll-haml

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

I'm not sure it's an issue but more of a question... #6

Open franceindia opened 10 years ago

franceindia commented 10 years ago

Hi I'm new to Jekyll and liquid tags (but not HAML). With this plugin, I can pull in a basic haml partial using

{% haml footer.hml %}

My problem: The default Jekyll index page fails to compile when I try to convert index.html to index.haml. How should it be written? This is what I have...


%div#home
    %h1 Blog Posts
    .posts
        {% for post in site.posts %}
            %li
                %span {{ post.date | date_to_string }}
                »
                %a{:href => "{{ post.url }}"}
                    {{ post.title }}
        {% endfor %}

What am I missing? Thanks!

Uko commented 10 years ago

:+1:

Can we just use .haml pages that will be converted to .html?

Stratus3D commented 10 years ago

Anyone found a workaround for this issue? I really need keep the comon parts of my layouts in shared files.

felixkiss commented 10 years ago

In Haml, indentation has a special meaning (it represents the hierarchy).

Haml conversion happens before Liquid conversion, and all your Liquid commands are plain text for Haml.

Therefore, whenever using things like {% for %} or {% if %}, you are not allowed to indent the code block it is enclosing (There should never be 2 indentation levels between two Haml tags like .foo or %bar)

This should work:

%div#home
  %h1 Blog Posts
  .posts
  {% for post in site.posts %}
    %li
      %span {{ post.date | date_to_string }}
      »
      %a{:href => "{{ post.url }}"}
        {{ post.title }}
  {% endfor %}
gnclmorais commented 8 years ago

@felixkiss, thank you for that example, it helped me to make it work! :raised_hands: