Skip to content

Commit

Permalink
Copy the ivars from the sinatra route to the mustache
Browse files Browse the repository at this point in the history
This makes your mustache behave more accordingly with what you'd expect
from a sinatra view: if you set an ivar on the route, you want it
available on your mustache.
  • Loading branch information
foca authored and defunkt committed Oct 6, 2009
1 parent 228768d commit d9cf588
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/mustache/sinatra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def render_mustache(template, data, options, locals, &block)
instance = Mustache.new
end

instance_variable_names.each do |name|
instance.instance_variable_set(name, instance_variable_get(name))
end

locals.each do |local, value|
instance[local] = value
end
Expand Down

0 comments on commit d9cf588

Please sign in to comment.