From aafb3ed9f223a6623b40ed90ebc1b64e2c31090e Mon Sep 17 00:00:00 2001 From: "Mark H. Wilkinson" Date: Tue, 12 Apr 2011 14:24:26 +0100 Subject: [PATCH] Fix behaviour of Context#stack when Context#push raises. We only want to pop the scope at the end of the method if pushing it succeeded, so the push needs to be outside the block with the ensure. --- lib/liquid/context.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index d37cf91..3ff8dfa 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -88,9 +88,12 @@ module Liquid # context['var] #=> nil def stack(new_scope={}) push(new_scope) - yield - ensure - pop + + begin + yield + ensure + pop + end end def clear_instance_assigns