Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 437
Andrea Sindico Avatar asked Oct 24 '16 19:10

Andrea Sindico


People also ask

Is pug better than HTML?

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.

How do you use pug variables?

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.


1 Answers

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

select
  each variable in variables
    option(value=variable.id) #{variable.var_name}
like image 79
Jacopo Brovida Avatar answered Oct 05 '22 12:10

Jacopo Brovida