When I try to incorporate the example YAML-data example from "Middleman 1.1" in a toy change to the supplied index.html.haml file:
- content_for :head do
%title The Middleman!
%h1 The Middleman is watching.
%h2 This is a test!
= some_helper(1)
%br
= trial_helper(2)
%br
= lorem.sentence
%br
%br
%h1 Friends
%ul
- x = data.people
= "X: " + x.inspect
%br
= x["friends"].inspect
-x["friends"].each do |f|
%li= f
%br
%br
%h2 YAML:
%h3 Friends
%ul
- data.people.friends.each do |f|
%li= f
I get:
NoMethodError at /
undefined method `friends' for {"friends"=>["tom", "dick", "harry"]}:Hash
However, with the example ruby code dismantled a little, it (inelegantly) works:
- content_for :head do
%title The Middleman!
%h1 The Middleman is watching.
%h2 This is a test!
= some_helper(1)
%br
= trial_helper(2)
%br
= lorem.sentence
%br
%br
%h1 Friends
%ul
- x = data.people
= "X: " + x.inspect
%br
= x["friends"].inspect
-x["friends"].each do |f|
%li= f
Produces:
The Middleman is watching.
This is a test!
Helper 1
Trial Helper
Sed aut consequatur iure autem
Friends
X: {"friends"=>["tom", "dick", "harry"]}
["tom", "dick", "harry"]- tom
- dick
- harry
What am I missing/doing wrong?
Thanks,
--Rick