Closed cjmarkham closed 10 years ago
I am using ECT with SailsJS. I have called res.view() within a controller and included the parameters for the template:
res.view()
res.view({ title: 'home', forums: forums });
forums is an object with several children. A console.log() of this object on the server shows all of the properties.
forums
console.log()
However, when I use this object in the ECT template I get nothing
<% for forum in @forums %>
I decided to output the contents of @forums and encode it using JSON.
@forums
<%= @helpers.jsonEncode @forums %>
(jsonEncode helper is just using JSON.stringify).
This does indeed output the whole object. So why is nothing rendered in my for loop
for
Try <% for forum of @forums %>
<% for forum of @forums %>
You are trying to walk through object as an array. @yuri-karadzhov suggested solution will solve your problem. You can use http://js2coffee.org/ to check your CoffeeScript syntax.
I am using ECT with SailsJS. I have called
res.view()
within a controller and included the parameters for the template:res.view({ title: 'home', forums: forums });
forums
is an object with several children. Aconsole.log()
of this object on the server shows all of the properties.However, when I use this object in the ECT template I get nothing
<% for forum in @forums %>
I decided to output the contents of
@forums
and encode it using JSON.<%= @helpers.jsonEncode @forums %>
(jsonEncode helper is just using JSON.stringify).
This does indeed output the whole object. So why is nothing rendered in my
for
loop