Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.
This repository was archived by the owner on May 8, 2024. It is now read-only.

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

@frasermarlow

Description

@frasermarlow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions