node.js - 使用 Jade 模板局部变量设置输入值

标签 node.js express pug

我想将用户配置文件中的输入值设置为其数据库值(如果存在)。我尝试使用 jade 中的参数传递来实现此目的,但出现以下错误:

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

但是当我渲染此模板时,我会以本地人的身份向其发送电子邮件

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

我还尝试将输入值设置为 !{email} 和 #{email} 但没有任何效果。有什么帮助吗?

谢谢, 费拉斯

最佳答案

res.重定向? res.render 你的意思是?您也不需要本地变量:{},只需 res.render('profile', { email: 'foo' })

关于node.js - 使用 Jade 模板局部变量设置输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10375521/

相关文章:

sql-server - 具有 SQL Server (Microsoft) 数据库连接的 Node

node.js - 如何为带有参数和关系的方法编写远程钩子(Hook)

javascript - HTTP header 上的多个值

html - Jade/Pug - 扩展布局 - 无法识别变量

html - 无法使具有固定高度和宽度响应的背景图像的 div

javascript - promise 未返回预期值

node.js - Node : How do I store data in an express session, 以便我可以从 socket.io 访问它?

node.js - 将 expressjs 绑定(bind)到特定的 IP 地址

mysql - 在nodejs中使用现有的mysql模式

pug - 如何使 Sails js 中的链接器与 Jade 一起使用?