在 Facebook中包含 .erb标签

发布于 2024-12-03 00:57:36 字数 409 浏览 0 评论 0原文

我在让 Facebook 识别包含 .erb 标签时遇到了很多麻烦。这是一个示例:

<meta property="og:title" content="Projects <%= @company.name.present? ? ('with ' + @company.name) : '' %>" />

这是一些详细信息:

  1. 页面源代码完整地显示了元标题,正如我所期望的那样。
  2. 我将 logger debug @company.name 放在元标记的正上方,我看到了预期的结果。
  3. 在FB上,我看到的都是“Projects”。

你知道这是怎么回事吗?

I've been having a lot of trouble getting Facebook to recognize <meta> tags that contain .erb. Here's an example:

<meta property="og:title" content="Projects <%= @company.name.present? ? ('with ' + @company.name) : '' %>" />

Here's a few details:

  1. The page source shows the meta title fully and as I would expect.
  2. I put logger debug @company.name right above the meta tag and I'm seeing the expected result.
  3. On FB, all I see is "Projects".

Do you know what's going on here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷途知返 2024-12-10 00:57:36

尝试使用 ' ' 而不是 " " ;例如:

   <meta property="og:description" content='<%= @job_details.description %>' />

这不应截断字符串

Just try to use ' ' instead of " " ; ex:

   <meta property="og:description" content='<%= @job_details.description %>' />

This should not truncate the string

沧桑㈠ 2024-12-10 00:57:36

这是因为你将红宝石包含到字符串中是错误的。

"Projects <%= @company.name.present? ? ('with ' + @company.name) : '' %>"
--> "Projects <%= @company.name.present? ? ('with ' + @company.name) : '' %>"

<%= "Projects #{ @company.name.present? ? ('with ' + @company.name) : '' }" %>
--> "Projects with Apple"

<%= "Projects " + @company.name.present? ? ('with ' + @company.name) : '' %>
--> "Projects with Apple"

选择最后两个解决方案之一来解决您的问题!

It's because your ruby inclusion into a string is wrong.

"Projects <%= @company.name.present? ? ('with ' + @company.name) : '' %>"
--> "Projects <%= @company.name.present? ? ('with ' + @company.name) : '' %>"

<%= "Projects #{ @company.name.present? ? ('with ' + @company.name) : '' }" %>
--> "Projects with Apple"

<%= "Projects " + @company.name.present? ? ('with ' + @company.name) : '' %>
--> "Projects with Apple"

Choose one of the two last solutions to fix your issue !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文