Cannot access 'locals' method on resource

Hello,

In the config.rb file I have created a proxy for all category values:

data.categories.collect{|categories| categories}.each do |category|
  proxy "/categories/#{category.name.gsub(" ", "_")}.html", "/categories/category_template.html", :locals => {:category => category}, :ignore => true
end

Then, on the main page, I would like to create a link to each of these categories. Instead of building the link url myself again from the categories in the data object, I would like to get the url and name from the list of site resources. I do the following in index.html.haml:

  - sitemap.resources.select{|p| p.destination_path.include?('categories/')}.each do |p|
    %li.list-group-item
      = p.locals

But here following error is thrown:

NoMethodError at /
undefined method `locals' for #<Middleman::Sitemap::Resource:0x007ffc2be229d8>

Could someone please assist and tell me why this isn’t working? Am I doing something wrong?
According to the API the ‘locals’ field should be accessible: http://www.rubydoc.info/github/middleman/middleman/Middleman/Sitemap/Resource
Or is this locals field not available on all locations?

Thanks in advance for any input.

I figured out a workaround:

in config.rb:

data.categories.each do |category|
proxy category_url(category), “/categories/category_template.html”, :locals => {:category => category, :lists => data.lists.select{ |list| list.category_id = category.id}.sort{|a, b| b.id <=> a.id}}, :ignore => true
end

then in the helper class:

  def category_url(category)
    "/categories/#{category.name.gsub(' ', '_')}"
  end

and in the template:

  • data.categories.each do |category|
    %li.list-group-item
    %span.badge
    = blogs_for_category(data.categories.first.id).size
    = link_to category.name, category_url(category)

So basically I reconstruct the URL to a resource whenever I need a link, but using a helper method.