tdreyno/middleman — pull request #185 by bhollis (2011-12-07 08:04:24+00:00)
Title: Don't share instance vars between different pages

This bit me today while working on moving my site over from staticmatic. I used to use instance variables set in my template (@title, etc) to communicate back to my layout fairly frequently. However, because Middleman renders each view with the same context, setting a variable in one page meant that the variable was still set when it went to render another page. This let to hard-to-track-down bugs where pages would render differently depending on what order they were build/previewed in.

I've switched everything over to using frontmatter now, but I think this is behavior that might bite more people than me, so I put together a scenario for using instance vars, and made it so each page renders with its own clone of the base context.