Display data inside input value using Jade Display data inside input value using Jade express express

Display data inside input value using Jade


Pug 0.1.0 (Jade 2.x) removed support for interpolation in attributes, so this works now:

input(type="text", name="date", value=viewpost.date)

See https://github.com/pugjs/pug/issues/2305


You can try enclosing the variable in #{} to output it:

input(type="text", name="date", value="#{viewpost.date}")


I realize this is old news, but I found that neither of these worked, and ended up doing it like this, for anyone stumped like I was:

input(type="text", placeholder=data.string)

and then in a script:

$(document).on('focus', 'input', function(){    var text = $(this).attr('placeholder');    $(this).val(text);})

thx