Monday 15 April 2019

conditional statements - Jade radio button checked condition

I have form in Jade file, and I want it to be pre-filled with some values that come from backend.In the form, there are radio buttons for user gender.


input(type="radio", name="gender_filter", value="1") Male
input(type="radio", name="gender_filter", value="0") Female

Now I also have this variable gender_param, and I want the corresponding button to be selected when page loads.
In PHP, I could do this:


>

Is there the corresponding syntax for Jade? Or I need to write it in the long way with line duplicates like


- if gender_param==1
input(type="radio", name="gender_filter", value="1", checked) Male
- else
input(type="radio", name="gender_filter", value="1") Male

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...