I’m having some trouble passing JSON data into a proxy page via a local variable. My build works, but still throws an error:
I’ve got a data file, data/designs.json
that is a nested JSON file that looks like this:
{
"designs": [
{
"name": "Name",
"slug": "slug",
}
}
I’m generating proxy pages for each of the entries in my designs.json
file above. In my config.rb
I’ve got:
data.designs.designs.each do |design|
proxy "/design/#{design['slug']}.html", '/design/template.html', :layout => false, :locals => { :title => design }
end
Where I’m trying to use the local variable title
to contain a single entry from my JSON file. In the /design/template.html.erb
file referenced above, I try to call that title
variable a few times:
image_path = "/source/images/design/#{title['slug']}.jpg"
image_url = "images/design/#{title['slug']}.jpg"
When I run middleman build
, it actually builds everything correctly. However, it always tells me it’s throwing an error:
undefined local variable or method `title' for #<Middleman::Application:0x2167500520>
Normally, I’m just ignoring the error since all my pages still build properly, however I’d like to use Middleman-deploy to push up my changes, and it doesn’t work while there is an error.
Any ideas on what might be going wrong here?