Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Haml and categories listing error #2

Open
dab opened this issue Jul 26, 2009 · 1 comment
Open

Haml and categories listing error #2

dab opened this issue Jul 26, 2009 · 1 comment

Comments

@dab
Copy link

dab commented Jul 26, 2009

Found that when i add
- for post in site.categories.work

to my haml template i get error

(haml):10:in `render': undefined method `work' for #<Hash:0x1a77ff0> (NoMethodError)
    from /usr/local/lib/ruby/gems/1.8/gems/haml-2.2.2/lib/haml/engine.rb:167:in `render'
    from /usr/local/lib/ruby/gems/1.8/gems/haml-2.2.2/lib/haml/engine.rb:167:in `instance_eval'
    from /usr/local/lib/ruby/gems/1.8/gems/haml-2.2.2/lib/haml/engine.rb:167:in `render'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/convertible.rb:72:in `render_haml_in_context'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/convertible.rb:88:in `do_layout'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/page.rb:45:in `render'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:223:in `transform_pages'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:213:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:213:in `transform_pages'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:212:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:212:in `transform_pages'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:126:in `process'
    from /usr/local/lib/ruby/gems/1.8/gems/henrik-jekyll-0.5.2/bin/jekyll:135
    from /usr/local/bin/jekyll:19:in `load'
    from /usr/local/bin/jekyll:19

But if i use liquid for this:

{% for post in site.categories.work %}
  <li>{{ post.title }}</li>
{% endfor %}

It works fine. Need advice, how to correct this issue.

@henrik
Copy link
Owner

henrik commented Jul 27, 2009

To get the payload (site.categories etc) into Haml, I turn it into a context object with accessors: a ClosedStruct (an OpenStruct that raises on missing attributes). But it's not applied recursively. If I find time I may look at how Liquid implements this. Until then, something like

site.categories['work']

should probably work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants