We have been working for several years on Middleman, the static HTML site builder. After a recent upgrade we have run into an issue that has our whole team stumped. In the config.rb all proxy calls work fine until we try to run a nested loop like this:
data.site.datatype.each do | id, c |
puts c
data.site.datatype.each do | id, c2 |
puts c2
end
end
[Note that data.site.datatype are .yaml files imported using middleman-contentful.]
The behavior is that the outer loop runs fine but the inner loop refuses to execute.
The output of the outer loop (puts c) shows the middleman import of the .yaml payload as follows:
#<Middleman::Util::EnhancedHash id="id-1" name="comp1" slug="comp1">
#<Middleman::Util::EnhancedHash id="id-2" name="comp2" slug="comp2">
We have been stuck on this issue for a week now so any guidance would be very welcome!
The Gemfile is as follows:
source 'https://rubygems.org'
gem 'middleman', '~> 4.2'
gem 'middleman-autoprefixer', '~> 2.7'
gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby, :x64_mingw]
gem 'wdm', '~> 0.1', platforms: [:mswin, :mingw, :x64_mingw]
gem 'middleman-dotenv', '~> 2.0'
gem 'contentful_middleman', '~> 4.2.0'
Otherwise the config.rm has activate :dotenv and activate :contentful
We have gone back to https://middlemanapp.com/advanced/dynamic-pages/ and can't find anything there that helps.
Update: While we have not found any real documentation on this, here is the answer.
While the use of
data.siteworks in the .html.erb templates, in config.rb the call to the data files requires@app.data.site.So the example code above should read
The hint came from the Middleman repo:
https://github.com/middleman/middleman/blob/master/middleman-core/lib/middleman-core/core_extensions/data.rb#L15-L19