【问题标题】:Pug (Jade) templating engine is malforming my stringPug (Jade) 模板引擎使我的字符串变形
【发布时间】:2020-11-16 05:39:46
【问题描述】:

如果我在后端创建一个测试函数,例如:

function testFunction(){

  return 'https://test.com/?test=erhc0m24t0v&url=https%3A%2F%2Fwww.groupon.com%2Fdeals%2Fbienestar'

}

然后我在渲染时将它传递给视图,并从我调用的视图中:

script.
      console.log('#{testFunction()}')

它通过添加我认为是 url 编码的空格和分号来破坏我的字符串:

https://test.com/?test=erhc0m24t0v&url=https%3A%2F%2Fwww.groupon.com%2Fdeals%2Fbienestar

而预期的输出很简单:

https://test.com/?test=erhc0m24t0v&url=https%3A%2F%2Fwww.groupon.com%2Fdeals%2Fbienestar

是什么导致这种情况发生?谢谢

【问题讨论】:

    标签: javascript html node.js pug


    【解决方案1】:

    您正在使用 转义 字符串插值#{
    尝试使用 unescaped 字符串插值!{

    来源:Pug's interpolation reference

    【讨论】:

    • 谢谢你猜不到,感激不尽。
    猜你喜欢
    • 2011-06-26
    • 2021-01-13
    • 2012-02-02
    • 2013-07-22
    • 1970-01-01
    • 2017-12-21
    • 2011-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多