Skip to content
Advertisement

Pug – generating Select and Options

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

Advertisement

Answer

Indents the code https://pugjs.org/language/iteration.html

select
  each variable in variables
    option(value=variable.id) #{variable.var_name}
Advertisement