On Mar 7, 2013, at 21:07, [email protected] wrote:

> So, here's my main home page (/) route - in the router.js file:
> 
>     app.get('/', function(req,res){
>         // check if the user's credentials are saved in a cookie //
>         if (req.cookies.user == undefined || req.cookies.pass == undefined){
>             res.render('index');
>         }
>         else {
>             res.render('index', {username: req.cookies.user});
>         }
>     });
> 
> However, how do I dynamically render data on the home/main/index page such as 
> different list of events.

> One way I am thinking I can do this is implement some logic in the app.get 
> route before I render index like so:
>     app.get('/', function(req,res){
>         // check if the user's credentials are saved in a cookie //
>         if (req.cookies.user == undefined || req.cookies.pass == undefined){
>             eventArray = getAllEvents(list, fn);
>                ....callback logic...
>               if (!events){
>                   res.render('index');
>                }
>                else  {
>                   res.render('index', {event 1 data, event 2 data, event 3 
> data...});
>                 }
>         }
>         else {
>             res.render('index', {username: req.cookies.user});
>         }
>     });
> But this looks like a bad way to code this - no?

That seems like a reasonable solution. What do you think it's a bad way to code?

-- 
-- 
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.


Reply via email to