如何在元描述中使用®(How do I use ® in meta description)

编程入门 行业动态 更新时间:2024-10-23 19:33:17
如何在元描述中使用®(How do I use ® in meta description)

我有一个客户希望他们的元描述包含注册符号,但它给我一个无效的字符错误,并使用® 在说明中不转换为®。 使用ree-1.8.7和rails 3.1.1

一些附加信息,此页面描述作为@page_description保存在控制器中,然后以部分方式引入页面。 错误似乎发生在控制器中,因此我猜测必须有一种使用®符号的红宝石方式。

I've got a client who wants their meta descriptions to include the register symbol, but it gives me an invalid character error, and using ® doesn't translate to a ® in the description. Using ree-1.8.7 and rails 3.1.1

Some additional information, this page description is saved in a controller as @page_description and then brought in on the page in a partial. The error seems to be occurring in the controller, so I'm guessing there must be a ruby way of using the ® symbol.

最满意答案

使用html_safe方法将字符串呈现为html。

试试@page_description.html_safe


编辑1:

® 是html中®的字符实体引用。

默认情况下,Rails不会将字符串呈现为html。

为了覆盖此行为,您需要使用html_safe将字符串呈现为html。

Use html_safe method to render the string as html.

try @page_description.html_safe


Edit 1:

® is the character entity reference for ® in html.

Rails does not render string as html by default.

In order to override this behaviour, you need to use html_safe to render the string as html.

更多推荐

使用,error,方式,电脑培训,计算机培训,IT培训"/> <meta name="description"

本文发布于:2023-07-31 19:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1347263.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   meta   description

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!