jekyll-haml
jekyll-haml copied to clipboard
I'm not sure it's an issue but more of a question...
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!
:+1:
Can we just use .haml pages that will be converted to .html?
Anyone found a workaround for this issue? I really need keep the comon parts of my layouts in shared files.
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 %}
@felixkiss, thank you for that example, it helped me to make it work! :raised_hands: