I'm using NodeJs with Express, Jade, MongoDB, Mongoose etc.
So I have a form with a checkbox that gets POSTed in an object in my mongoDB database using Mongoose as a Boolean, true or false.
.checkbox
input(type="checkbox", name="roundTrip", checked=(true || false))
I'm trying to use Jade to display a list of all the objects in my collection, so I passed in the an array of the objects to my '/ridelist' using res.render called rides.
But when I try to us an if statement in Jade to read the status of the checkbox, I get errors and it doesn't seem to work.
Here is what I want to do, but doesn't work:
h1.
List of Rides
ul
each ride in rides
li
p Destination: #{ride.destination}
p Departure: #{ride.dateLeaving}
p Round Trip: #{ride.roundTrip}
if #{ride.roundTrip} //- THIS GIVES ME AN ERROR
p Time departing for return: #{ride.dateReturning}
Without the last two lines it renders like:
List of Rides Destination: Santa Cruz Departure: Friday 5pm Round Trip: true Destination: Chico Departure: Saturday 4am Round Trip: false
But the if statement is messing me up.
Aucun commentaire:
Enregistrer un commentaire