I am new to Pug and I am trying to generate a Select set of Options like this:
select
each variable in variables
option(value=variable.id) #{variable.var_name}
However the result I get, in the rendered page, is an empty select input followed by the list of options as text
In ASP.NET or PHP code, your HTML is still there and you script it. Whereas Pug is a different story in itself. Now, after the Pug, we also need to understand what Pug can do for us. Pug is an excellent framework but HTML is the standard.
The names of the variables in your Pug file become siteColors and siteNames . To set the entirety of an HTML element equal to a variable, use the equals operator = to do so. If your variable needs to be embedded inline, use bracket syntax #{} to do so.
Indents the code https://pugjs.org/language/iteration.html
select
each variable in variables
option(value=variable.id) #{variable.var_name}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With