【问题标题】:display variable value using pug template engine inside textarea在 textarea 中使用 pug 模板引擎显示变量值
【发布时间】:2018-12-06 07:30:27
【问题描述】:

我从 mongodb 获取数据,当在文本区域的 pug 中显示变量值时,描述变量 <hello my name is ahmed></hello my name is ahmed> 的输出 存储在描述中的数据只是hello my name is ahmed 代码在视图中

.row
    .col-md-6
          .form-group
                label(for='inputPassword3') Description
                textarea#inputPassword3.form-control(name="description", cols="30", rows="10" placeholder="Description") 
                    if user.description != undefined || user.description != null
                        #{user.description}

【问题讨论】:

    标签: javascript node.js pug


    【解决方案1】:

    它与 pug 模板引擎显示值有关,我们应该使用 | #{user.description} 以避免将变量值转换为文本区域内的标记,因此更新的代码将是

      `.row
            .col-md-6
                .form-group
                    label(for='inputPassword3') Description
                    textarea#inputPassword3.form-control(name="description", cols="30", rows="10" placeholder="Description") 
                        if user.description != undefined || user.description != null
                            | #{user.description}` 
    

    【讨论】:

      猜你喜欢
      • 2021-01-13
      • 1970-01-01
      • 1970-01-01
      • 2018-10-01
      • 2020-11-16
      • 1970-01-01
      • 1970-01-01
      • 2011-06-26
      • 1970-01-01
      相关资源
      最近更新 更多