Feras Odeh
Feras Odeh

Reputation: 9296

set Input value using Jade template locals

I want to set input value in my user profile to its db values if they are exists. I tried to use parameter passing in jade for this but I got the following error:

referenceError: /Users/Feras/Sites/wowito/views/profile.jade:13
    11|         fieldset(data-role='controlgroup') 
    12|          label.label(for='email')  EMail
  > 13|          input.input(id='email',type='text',value=email,name='email') 
    14|          label.label(for='firstName')  First Name
    15|          input.input(id='firstName',type='text',value='',name='firstName') 
    16|          label.label(for='lastName')  Last Name

email is not defined

but when I render this templat I send it email as locals

res.redirect('/profile',{locals :{email:"profile.email"}});

I tried also to set input value to !{email} and #{email} but nothing works. any help?

Thanks, Feras

Upvotes: 1

Views: 5265

Answers (3)

Tyler
Tyler

Reputation: 18177

I found that I had to wrap my variables in single quotes or else I got a unexpected token error:

input.input(value='#{email}')

Upvotes: 3

German Attanasio
German Attanasio

Reputation: 23663

You need to use #{ } to access variables

input.input(id='email',type='text',value=#{email},name='email')

Upvotes: -2

TJ Holowaychuk
TJ Holowaychuk

Reputation: 261

res.redirect? res.render you mean? also you dont need locals:{}, just res.render('profile', { email: 'foo' })

Upvotes: 4

Related Questions