How do I get jade to render the checked attribute of a checkbox based on a conditional? Like these two versions of the HTML checkbox tag:
This seems to be the ONLY valid version of unchecked:
> <input type="checkbox" name="vehicle" value="Bike">
While this is checked:
> <input type="checkbox" name="vehicle" value="Car" checked="checked">
Here is what I've tried so far:
This Jade is fine:
input(type="checkbox", name="completed", checked=(true===true ? "checked" : "")).checkbox
because it renders this:
<input type="checkbox" name="completed" checked="checked" class="checkbox">
but this Jade is not fine:
input(type="checkbox", name="completed", checked=(false===true ? "checked" : "")).checkbox
because it renders this:
<input type="checkbox" name="completed" checked="" class="checkbox">
instead of this:
<input type="checkbox" name="completed" class="checkbox">
How do I get Jade to render the entire checked attribute instead of just the value of the checked attibute?
You can use:
input(type="checkbox", name="completed", checked=(true===false ? "checked" : undefined))