Closed jsturnio closed 4 years ago
I'm sorry I started on a reply to this back in October, but missed that I had not actually posted the reply...
If you launch your script from the command line using >node myscript.js
then it will run with no attached debugger and so will not provide full debugging information. You will just get the call stack of any exception that is thrown, as you show above.
You can launch the script with a debugger, and it will pause at the exception, and you can see the error message. For example you can debug in chrome, by navigating to about:inspect
and then clicking on "Open dedicated DevTools for Node".
Then you can launch with debugger from your command window:
> node --inspect-brk myscript.js
If you don't want to run with a debugger, you can still get the full error message by modifying your script file and putting a try catch block around the code for which you want to see the error messages on any exceptions. In the catch block you can write the message back to the console:
var $ = require('jsrender');
try {
var tmpl = $.templates('Name: {{:name}}<br/> {{tagne/}} ');
var html = tmpl.render({name: "Jim"}); // Render
}
catch (e) {
console.log(e)
}
console.log(html);
which will output
{ Error
... (call stack)
at Object.<anonymous> (...mysript.js:1:9)
name: 'JsRender Error',
message:
'Unknown tag: {{tagne}}'
}
@jsturnio - I didn't hear back from you. Did the above suggestions work for you? Closing this issue.
Hi Boris, thank you about your clear suggestions!! I tested and work fine and sorry for my late answer.
And by the way, your documentation is very nice and clear!
Hi, I'm trying to use JsRender with Node to generate static source code, but I found that if I use a HTML page, everything is OK, if I use a tag that is not defined for instance, the error is shown in console.
Now if I use Node with JSRender (installed with: npm install jsrender --save ), then I tried the following example:
It works Ok, it prints: Name: Jim
But if I try to use a tag that does not exist, the template line is now:
var tmpl = $.templates('Name: {{:name}}<br/> {{tagne}} ');
I get the following output:How I can get the right error message? I tried also to test an example that use a custom tag, but I can not fix it (because I got the same error message), however, the same example is working fine an HTML I'm using node 10.15.2 and jsrender 1.0.5 Thanks in advance,