From 794ca9f604ec223c57b7f03b661dcf9930b02534 Mon Sep 17 00:00:00 2001 From: Tom Burns Date: Wed, 30 Jul 2014 15:42:24 +0000 Subject: [PATCH] make the conditions around stack creation easier to read --- lib/liquid/context.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index a075b26..efd74cb 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -137,8 +137,13 @@ module Liquid # context['var] #=> nil def stack(new_scope=nil) old_stack_used = @this_stack_used - @this_stack_used = (new_scope != nil) - push(new_scope) if @this_stack_used + if new_scope + push(new_scope) + @this_stack_used = true + else + @this_stack_used = false + end + yield ensure pop if @this_stack_used