as far as i now ejs (as most of other template engines) does not support
asynchronous helper. you have to fetch the comments first and then pass
them to your template rendering
in your controller:
function(req, res, params){
var debate = //resolve the debate
*
debate.getComments(function(err,comments){
*
*
console.log(comments.length);
self.respond({comments: comments, debate: debate})
});
*
}
in view
*<%= comments.length; %>*
Am Montag, 18. Februar 2013 20:16:51 UTC+1 schrieb Eric Ponce:
>
> Hi guys!
>
> I'm working in a Geddy.JS application and I have one problem with one
> function.
>
> In my view(in EJS) I have the next:
>
> *<%= h.comments(debate); %>*
> *
> *
> My problem: When we go to the "comments" function, we have:
> *
> *
> *
> exports.comments = function (debate) {
> debate.getComments(function(err,comments){
> console.log(comments.length);
> return comments.length;
> });
> };
>
> My app doesn't print anything, but CONSOLE.LOG prints all perfect.
> How can I return the value and print it into the view?
>
> Thanks to all!!!!
> *
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.