Closed robbertbrak closed 6 years ago
You are right, having error messages rendered at the individual tag level, rather than the template/block level, would make for easier debugging, and would conserve more of the correct about from the template rendering. Historically the debugMode(true) was originally at the template block level, and the tag-level onError overrides were not yet implemented. But now that tag-level code is there it is actually possible to change the default debugMode(true) behavior to be at the tag level. I have made that change in my current working version of the next JsViews/JsRender update. It is technically a breaking change, but I think I prefer to change the default behavior rather than introduce an additional new alternative debug mode.
I have attached the working copies of jsrender.js and jsviews.js. Can you test out whether the change works for you, and let me know if there are any issues?
jsrender.js.txt jsviews.js.txt
Thanks.
It seems to work pretty well, thanks!
I briefly tested various settings of debugMode
, such as debugMode(true)
, debugMode(false)
, debugMode('foo')
, debugMode('')
and debugMode(myErrorFunc)
, with and without onError
overrides at the tag level. Both jsrender.js and jsviews.js behave exactly as I would expect.
Excellent. Thanks for testing it!
This feature change has been made in commit 89
From the documentation:
That's nice, but if a template block is very large, it can be difficult to track down bugs in individual tags.
How about adding a debug mode that acts as if an error handler was added to each individual tag?
Taking the example from the documentation, if this debug mode is used, the template below:
...with this data:
...would render as: