【问题标题】:Rails 5.2: apostrophe (single quote) in YAML renders as ' in title attributeRails 5.2:YAML 中的撇号(单引号)在标题属性中呈现为 '
【发布时间】:2019-07-08 01:55:16
【问题描述】:

如果不向我的所有 YAML 键添加 _html 后缀,以防外语需要包含单引号/撇号字符,我怎样才能让这样的字符在标题属性中正确呈现HTML 标记?

就我而言,在 fr.yml 我有:

Report_this_comment:“Signaler ce commentaire pour violation de nos 使用条件"

我用这个来渲染这个:

<a href="..." title="Signaler ce commentaire pour violation de nos conditions d&#39;utilisation">Signaler</a>

我不希望将鼠标悬停在链接上时出现在工具提示中的&amp;#39;。我只想要一个撇号。

我读过的双单引号技术只给了我两个相邻的&amp;#39;。并用反斜杠作为前缀,即。

Report_this_comment:“Signaler ce commentaire pour violation de nos 条件d\'利用"

在渲染页面时导致服务器错误。

This SO answer from 2013 有效 - 它使用单引号。当然,使用这些方法很痛苦,所以我想知道是否有人有更好的当前解决方案。

【问题讨论】:

    标签: ruby-on-rails yaml


    【解决方案1】:

    只需删除 fr.yml 中的双引号,试试这个:

    Report_this_comment: Signaler ce commentaire pour violation de nos conditions d'utilisation
    

    【讨论】:

    • 不,这没有任何区别。
    猜你喜欢
    • 1970-01-01
    • 2013-08-13
    • 1970-01-01
    • 2017-03-11
    • 2020-04-11
    • 2017-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多