Note that there are some explanatory texts on larger screens.

plurals
  1. POJade template rendering error div despite undefined errors object
    primarykey
    data
    text
    <p>When hitting my sign-up page my jade template (with Twitter Bootstrap) is producing an empty error div (i.e. a red, opaque box with a closing link and no errors), despite the errors object returning typeof as 'undefined'. I've used <a href="https://stackoverflow.com/questions/858181/how-to-check-a-not-defined-variable-in-javascript">this post</a> for guidance on checking the value of errors. The code follows:</p> <p><strong>The controller:</strong></p> <pre><code>/** * Show sign up form */ exports.signup = function(req, res) { res.render('users/signup', { title: 'Sign up', user: new User() }); }; </code></pre> <p><strong>The Jade template:</strong></p> <pre><code>extends ../layouts/default block content .row //-.offset1.span5 .span6 a(href="/auth/facebook") img(src="/img/icons/facebook.png") //- a(href="/auth/github") //- img(src="/img/icons/github.png") a(href="/auth/twitter") img(src="/img/icons/twitter.png") a(href="/auth/google") img(src="/img/icons/google.png") .span6 if (typeof errors != 'undefined') // The following alert shouldn't be rendered .fade.in.alert.alert-block.alert-error a.close(data-dismiss="alert", href="javascript:void(0)") x ul each error in errors //- li= error.param li= error.msg block auth </code></pre> <p>I've tried the following, but get the same result every time:</p> <pre><code>if (typeof errors != 'undefined') if (typeof errors !== 'undefined') if (typeof errors != undefined) if (typeof errors !== undefined) if (null != errors) if (null !== errors) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload