visionmedia/jade — Issue #478: Iterator erroring inside an if
Author: micho
Created: 2012-01-16 11:04:25+00:00
State: open

The code below errors with:

Error rendering template partials.comment_form_watchers
object is not a function
TypeError: object is not a function
at Array.CALL_NON_FUNCTION (native)
at eval at (http://localhost:3000/assets/lib/jade-0.15.4:816:8)
at Object.partials.comment_form_watchers (http://localhost:3000/assets/lib/jade-0.15.4:821:12)

Code that errors:

- var project_id = self.project_id || (self.model && self.model.get('project_id'))
- users = self.Teambox.helpers.projects.getUsers(project_id)
- for u in users
option(value= u.id)= self.full_name(u)

This code works:

- var project_id = self.project_id || (self.model && self.model.get('project_id'))
- users = self.Teambox.helpers.projects.getUsers(project_id)
- if (project_id)
- for u in users
option(value= u.id)= self.full_name(u)

Looks like the iterator doesn't like to be after the if.