gschlossnagle / json-template

Automatically exported from code.google.com/p/json-template
0 stars 0 forks source link

Better handle undefined variables #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
$console.log(jsontemplate.Template('vvv={vvv}').expand({xxx:10}))

Generate an exception difficult to intercept and on real/complex 
applications it is possibile that variables are not present in the json 
object.

I've made a patch that detects this situation, logs it and return an empty 
String to let the program execution continue without exceptions

I'll find it useful and think others too..

Thanks, Francesco.

Original issue reported on code.google.com by fstr...@gmail.com on 3 Jul 2009 at 7:06

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the patch.  But you can use undefined_str in the latest version to 
make
the empty strings not throw undefined variable.  This is only in head -- I'll 
update
the pre-release files tomorrow.

Also, the null values throwing the exception is a bug that's not yet fixed: 
issue 21.
 So your instinct was right there.

Original comment by gtempacc...@yahoo.com on 3 Jul 2009 at 8:34

GoogleCodeExporter commented 8 years ago
The release is now in the downloads area.  Let me know if this doesn't solve 
your
problem.

Original comment by gtempacc...@yahoo.com on 10 Jul 2009 at 6:30