| Issue 30: | The JS version is not reentrant -- thus impossible to have templates include other templates | |
| 1 person starred this issue and may be notified of changes. | Back to list |
The JS version is not reentrant -- thus impossible to have templates include other templates. Things like the stack, which while hidden in a module pattern, is still a global to the functions.
Sep 14, 2009
Project Member
#1
sroussey
Sep 14, 2009
Nice catch, but what scope are 'statement' and 'i' being read from? I don't see it. What environment are you running in, a browser? It is definitely intended to be fully reentrant.
Sep 14, 2009
In a browser... and the statement and i are being read in those same functions... since I have templates including other templates, the same functions get called. So template A includes B which changes the i and statement such that when it gets back to A, it thinks it hasn't included B yet and starts all over again.
Sep 14, 2009
OK, so in JavaScript, if you don't use "var", then the variables automatically become globals? Weird. Do you have a snippet that can reproduce it? I can certainly just add "var" to those statements, but I would like a regression test too. That can go here: https://code.google.com/p/json-template/source/browse/trunk/javascript/browser_tests.py The browser_tests.py file generates an HTML file (via jsontemplate_test.py --browser-test-out-dir) that can be run in a browser.
Sep 14, 2009
var is the way to stop JS from moving up through all scopes to find the variable (thus is why and how closures work). A test would not be possible unless I added include functionality in the test...
Sep 14, 2009
OK fixed at head: https://code.google.com/p/json-template/source/detail?r=280
Status:
Fixed
|