My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
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
Status:  Fixed
Owner:  ----
Closed:  Sep 2009


 
Project Member Reported by sroussey, Sep 14, 2009
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
Silly me, it is just global leakage..

_Execute should have:

var statement;

_DoSubstitute should have :

var i;

They were using globals and effecting the rendering (infinite loop).
Sep 14, 2009
Project Member #2 gtempacc...@yahoo.com
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
Project Member #3 sroussey
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
Project Member #4 gtempacc...@yahoo.com
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
Project Member #5 sroussey
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
Project Member #6 gtempacc...@yahoo.com
OK fixed at head: https://code.google.com/p/json-template/source/detail?r=280

Status: Fixed

Powered by Google Project Hosting