contentful/contentful_middleman

After implementing locales, middleman config.rb won't allow nested loops.

Opened this issue · 1 comments

We recently implemented locales in Contentful, and are pulling the .yaml files into Middleman just fine.
Now we need to rework all of our templates with the localization helpers as every single object in the .yaml file now has a :en-US: level...

But one issue we have encountered is that when we were proxying pages in a nested loop, these are no longer working. We have spent ~16 people hours on this and can't get it to work.
I am hoping somebody may have run into something similar and can either sympathize or better still offer up a solution? :-)

Is there possibly a conflict between middleman_contentful and the i18n middleman module?

Here are examples of our previous and new version of the code:

# Build james pages
    data.oursite.alljamess.each do |id, james|
      proxy "vs/#{james.slug}/index.html", "james.html", locals: { james: james }, :ignore => true
      data.oursite.alljamess.each do |id, james2|
        if james.name != james2.name
          proxy "vs/#{james.slug}/#{james2.slug}/index.html", "james_james.html", locals: { james: james, james2: james2 }, :ignore => true
        end
      end
    end

And the new version:

# Build james pages
    data.oursite.alljamess.each do |id, james|
      proxy "vs/#{james['slug']['en-US']}/index.html?l288=true", "james.html", locals: { james: james }, :ignore => true
      data.oursite.alljamess.each do |id, james2|
        if james.name['en-US'] != james2.name['en-US']
          proxy "vs/#{james['slug']['en-US']}/#{james2['slug']['en-US']}/index.html", "james_james.html", locals: { james: james, james2: james2 }, :ignore => true
        end
      end
    end

From testing, we see the pages in the outer loop are generated, but the inner ones don't.

simply put:

# Build james pages
    data.oursite.alljamess.each do |id, james|
      puts "a"
      data.oursite.alljamess.each do |id, james2|
      	puts "b"
      end
    End

does not return abbbbbabbbbbabbbb... but returns aaaaaaaaaaaa

I think we found a way to get this working, although either this fix or simply the upgrade to the new Middleman version has caused our site to grind to a halt during middleman build
https://stackoverflow.com/questions/62976636/how-to-get-nested-loops-in-config-rb-to-work-in-middleman