]> Devi Nivas Git - chevron.git/commitdiff
Fixed _get_key returning prematurely
authornoah morrison <noah@morrison.ph>
Thu, 15 Jan 2015 20:02:41 +0000 (15:02 -0500)
committernoah morrison <noah@morrison.ph>
Thu, 15 Jan 2015 20:02:41 +0000 (15:02 -0500)
Variables were clobbering other variables... badness was happening.

When given
```test.ms
{{# container }}
  {{ sibbling.child }}
{{/ container }}
```

```test.json
{
    "container": [1,2,3],
    "sibbling": {
        "child": "Just me."
    }
}
```

it was returning
```wrong.txt
  {'child': 'Just me.'}
  {'child': 'Just me.'}
  {'child': 'Just me.'}
```

when it should have returned
```right.txt
  Just me.
  Just me.
  Just me.
```

chevron/renderer.py

index de23cbf561a4378156cfbe3b7bcae3ce35267932..ac2da27032a04ea86758ca743b355d5774597bd1 100644 (file)
@@ -53,9 +53,9 @@ def _get_key(key, scopes):
     for scope in scopes:
         try:
             # For every dot seperated key
-            for key in key.split('.'):
+            for child in key.split('.'):
                 # Move into the scope
-                scope = scope[key]
+                scope = scope[child]
             # Return the last scope we got
             return scope
         except (TypeError, KeyError):