Issue 27: Better handle undefined variables
Status:  Fixed
Owner: ----
Closed:  Jul 2009
Reported by fstr...@gmail.com, Jul 3, 2009
$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.
json-template.diff
969 bytes   View   Download
Jul 3, 2009
Project Member #1 gtempacc...@yahoo.com
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.

Jul 9, 2009
Project Member #2 gtempacc...@yahoo.com
The release is now in the downloads area.  Let me know if this doesn't solve your
problem.

Status: Fixed