Given the file data/publications.json
, I’d like to test that
- the
feature
key exists and - that the value is
true
and if both of those conditions are met, then print some other values into a haml template.
data/publications.json
looks like this:
{
"publications": [
{
"title": "Book title 1",
"author": "Arthur Author",
"summary": "The book's main chapters take you through building a social news site.",
"cover": "http://placehold.it/350x450",
"featured": "true"
}
]
}
and the haml code looks like this:
- data.releases.publications.has_key("feature").each_with_index do | publication |
.recent-item-wrapper
.recent-image
%img{:src => "#{publication.cover}", :width => "200px"}
.recent-meta
%h3=publication.title
%h4=publication.author
but it just produces an error. Can someone please help?
%p=publication.summary