middleman/middleman — Issue #264: Variable undefined in page layout
Author: JeanMertz
Created: 2012-02-09 16:36:45+00:00
State: open

I have this navigation in my layout.erb:

```erb

>Index

>Page2

```

Now I am trying to set the @page_name based on the current generated page, but I can't get @page_name to output anything (tested using `
<%= @page_name %>
`):

**config.rb**

```ruby
# this didn't work (found it in the issues here)

%W[ index page2 ].each do |name|
page "/" do
@page_name = 'test'
end
end

# this also didn't work
%W[ index page2 ].each do |name|
page "#{name}.html.erb" do
@page_name = name
end
end

# or this..
%W[ index page2 ].each do |name|
page "#{name}.html.erb", proxy: "layout.erb" do
@page_name = name
end
end
```

Any clues on what might be going on?