动态元描述撇号由'ASCII值替换

问题描述 投票:2回答:2

在我的meta-description(这是动态的)中,当我执行CTRL + U / View源和Google搜索时,撇号被'取代。

<meta name="Description" content="Discover Sonam Kapoor&#x27;s look in Dolly Ki Doli, Dolly/Madhuri/Priya/Bhagyashree,Red Net Kameez with Patiala,Red Art Silk Patiala Suit,RITIKA SACHDEVA Gold finish"

应该是“sonam kapoor's”,但我有“Sonam Kapoor&#x27; s”。如何解决这个问题?

我正在使用node.js,html,mongodb。

我在index.js中做了console.log并检查它是否正确打印了“Sonam Kapoor”,因此正确地从数据库中获取,但在网页查看源代码中它将出现“Sonam Kapoor&#x27; s”ASCII值。

html node.js mongodb seo html-encode
2个回答
1
投票

嗨,最后我使用以下代码解决了它

    Handlebars.registerHelper('asciim', function(text) {
  text = Handlebars.Utils.escapeExpression(text);
  return new Handlebars.SafeString(result);
});

谢谢大家


1
投票

编译Handlebars模板时,可以使用noEscape option避免自动HTML转义:

Handlebars.compile('{{foo}}', { noEscape: true })

请注意 - 如果您渲染任何user-generated content,这将是不安全的。

© www.soinside.com 2019 - 2024. All rights reserved.