【问题标题】:Dynamic meta description apostrophe is replaced by ' ASCII value动态元描述撇号替换为 ' ASCII 值
【发布时间】:2016-08-20 07:01:09
【问题描述】:

在我的meta-description(它是动态的)中,当我执行 CTRL + U / 查看源代码和 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"

它应该是“索南卡普尔”,但我有“索南卡普尔”。如何解决这个问题?

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

我在 index.js 中做了 console.log 并检查了它是否正确打印“Sonam Kapoor's”,因此可以正确地从数据库中获取,但在网页视图源代码中它是“Sonam Kapoor 's”ASCII 值。

【问题讨论】:

  • 你是如何插入元描述的?

标签: html node.js mongodb seo html-encode


【解决方案1】:

嗨,我终于用下面的代码解决了

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

谢谢大家

【讨论】:

    【解决方案2】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2012-04-19
      • 2015-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 2015-05-30
      相关资源
      最近更新 更多