jeremyruppel / walrus

A bolder kind of mustache
http://documentup.com/jeremyruppel/walrus/
MIT License
215 stars 10 forks source link

catch errors event #30

Open abelrgr opened 7 years ago

abelrgr commented 7 years ago

When I was trying to compile the template without the friends array (because data is dynamic):

<h1>{{name.first}} {{name.last}}</h1>
<ul>
   {{:each @friends do}}
   <li>{{name}}</li>
   {{end}}
</ul>

I get this message:

TypeError: Cannot set property '$index' of undefined at walrus.js:1125:24

There is any way to catch the errors to send over the rest server to show an error into the frontend?

I'm working over nodejs 7.x. BTW the other stuff works really great!

jeremyruppel commented 7 years ago

I'm sure there's a way to handle this error better! What would you prefer walrus do in this case? Should it simply ignore the :each block if the @friends array isn't present?

abelrgr commented 7 years ago

@jeremyruppel thanks for your answer :) , yeah, it should be better if the block is ignored if the block @friends is not present.

BTW, Walrus better than others in nodejs