Spot the bug … dynamic language slap-on-forehead moment

   edit
Follow


This is a view template rendering html. When running it, it caused the page to freeze (i.e. the page keeps loading).

 


<h3>Services</h3>

&lt;% for (var ix=0; ix < view.services.length; ++i) { %&gt;

   &lt;% var service = view.services[ix]; %&gt;

   &lt;p&gt; &lt;%=service.name %&gt; &lt;/p&gt;
&lt;% } %&gt;	

 

Took me a while to grasp it. I tried various things, thought that the templating-engine code was bad, blamed every line of code in the application, until I actually re-read the template code carefully

 

You see, the indexer is “ix” while the ++ is working on “i”.

 

Since it is Javascript, no “I do not know what i is” exception was thrown. Instead, the first time it was encountered, JS decided it equals zero, and then the poor thing just kept increasing, probably until it would have overflowed.

 

 

 

 

In case you have missed it, it was javascript. Not AspView, nor Jsp. I am using a new, super-simple javascript base templating engine, for places where embedding something like AspView would be an overkill, and using NVelocity would be as annoying as using NVelocity.

 

I hope to have it released as open source soon. Basically it is a simple transformer into simple JS code, and I’m using the supercool Jint libraryfor running it within .NET. I am also planning on making it available for Java at some point using Mozilla Rhino


     Tweet Follow @kenegozi