> select(name="mood")
> option(value="") -- Select Mood --
> option(value="happy", selected=(mood == 'happy') ? true : false)
> | Happy
> option(value="sad", selected=(mood == 'sad') ? true : false)
> | Sad
Certainly that can be simplified to:
select(name="mood")
option(value="") -- Select Mood --
option(value="happy", selected=(mood == 'happy'))
| Happy
option(value="sad", selected=(mood == 'sad'))
| Sad
And presumably these "Happy" and "Sad" values are really in an object...
var items = {
happy: "Happy",
sad: "Sad"
};
...or maybe an array...
var items = [
{
value: "happy",
label: "Happy"
},
{
value: "sad",
label: "Sad"
}
];
...that you pass into the jade template from your javascript code, so you can loop over them to make the select rather easily.