From fb3a43337ca69f18f2b702c079cce97377e1110f Mon Sep 17 00:00:00 2001 From: noah morrison Date: Sun, 25 Jan 2015 15:43:08 -0500 Subject: [PATCH] Stop using a leaked variable. (flake8) scope is a variable that is defined lower in the for loop and is leaked up in a future pass. Also this code was slightly convoluted. The goal is to stop rendering while the current scope is falsy. Adding a new falsy scopes for every section inside (So it doesn't start rendering on the next end tag). I don't really know what I was thinking when I first coded this, but all we have to do is add False instead of whatever in the world I was doing before. --- chevron/renderer.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/chevron/renderer.py b/chevron/renderer.py index a665122..86ab624 100644 --- a/chevron/renderer.py +++ b/chevron/renderer.py @@ -169,15 +169,10 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', # If the current scope is falsy and not the only scope elif not current_scope and len(scopes) != 1: - # If we're a section tag - if tag == 'section': - # Set it as the most recent scope - scopes.insert(0, scope) - - # If we're an inverted section tag - elif tag == 'inverted section': - # Set the flipped scope as the most recent scope - scopes.insert(0, not scope) + if tag in ['section', 'inverted section']: + # Set the most recent scope to a falsy value + # (I heard False is a good one) + scopes.insert(0, False) # If we're a literal tag elif tag == 'literal': -- 2.47.3