From: noah morrison Date: Sun, 25 Jan 2015 20:43:08 +0000 (-0500) Subject: Stop using a leaked variable. (flake8) X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=fb3a43337ca69f18f2b702c079cce97377e1110f;p=chevron.git 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. --- 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':