Reputation: 10812
I'm passing an object into my template. I've confirmed that the object is there:
input(type='text', name='cta', class='form-control', value= fdata, required, autofocus)
This renders the input with the full object in the input field:
{"_id":"54b852bf8128fb7d24723e70","__v":0,"cta":"Example text","logo":"uploads/bd6ef27f219be5bbbd0e4b3b8bb7a1db.jpg"}
This, however sets the value as undefined
:
input(type='text', name='cta', class='form-control', value= fdata.cta, required, autofocus)
as well as this:
input(type='text', name='cta', class='form-control', value= #{fdata.cta}, required, autofocus)
Is this normal? What am I missing?
Upvotes: 0
Views: 435
Reputation: 225291
Jade doesn’t JSON-encode objects for use in the value
attribute, so it appears you have a JSON string that you need to parse. You can do it in the template, but wherever fdata
comes from might be a better bet.
input(
type='text',
name='cta',
class='form-control',
value=JSON.parse(fdata).cta,
required,
autofocus)
Upvotes: 1