Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jade undefined variable

Tags:

node.js

Here is an example jade input:

The class variable is undefined

input.class(name="class", type="textfield", value="#{locals.class}")

This shows up as a form with undefined already set as the value. That's not what I want, if it's undefined then no text should appear.

I can also do this:

-if (locals.class) {
input.class(name="class", type="textfield", value="#{locals.class}")
- } else {
input.class(name="class", type="textfield", value="")
- }

But it seems fairly terrible/unusable if I have to do this for every input in every form across the app.

Is there anything I can do about this?

like image 703
Harry Avatar asked Oct 21 '11 05:10

Harry


1 Answers

Simple fix, you just have to have to remove the quotes and braces and it will print an empty string

input.class(name="class", type="textfield", value=locals.class)
like image 116
Donnie H Avatar answered Sep 18 '22 12:09

Donnie H