creationix / haml-js

Haml ported to server-side Javascript. This is a traditional server-side templating language. Tested with node-js
MIT License
900 stars 109 forks source link

Cryptic error message if trying to render 'undefined' #15

Closed redsquirrel closed 14 years ago

redsquirrel commented 14 years ago

If we pass an undefined value as the first argument to haml.render, we get the following error:

TypeError: (Haml): Cannot call method 'trim' of undefined at tokenize (/Users/redsquirrel/Projects/apprentice.us.com/vendor/haml/0.4.0/lib/haml.js:177:17) at <error: TypeError: Cannot read property '0' of undefined> at /Users/redsquirrel/Projects/apprentice.us.com/vendor/haml/0.4.0/lib/haml.js:624:18

Obviously, we shouldn't be passing an undefined value there, but a more revealing error would make debugging easier. :)

creationix commented 14 years ago

Could you send me a patch that checks the input and throws an error if it's undefined or some other bad value?

redsquirrel commented 14 years ago

Pull request sent from http://github.com/redsquirrel/haml-js

creationix commented 14 years ago

looks good, I just pushed it.