Thank you.
I was hoping there would be another way to deal with this - there's going 
to be so much processing/logic that I need to put in this else...
because for e.g.
Some events are featured events so they belong in appropriate 
parts/sections of the home page while others get smaller real estate on the 
home page and so on.

Thanks,
JP

On Friday, March 8, 2013 3:26:10 AM UTC-5, ryandesign wrote:
>
>
> On Mar 7, 2013, at 21:07, [email protected] <javascript:> 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