English 中文(简体)
将html的特性插入网页标题的助手
原标题:Inserting html characters into a page title helper

This problem is not critical... but would be helpful for me to know the answer. I ve been using Ryan Bates method of putting titles on pages. BTW, he s a great innovator and contributor to the rails community, isn t he?

申请-求助者档案:

  def title(page_title)
    content_for(:title) { page_title }
  end

排外文件:

<head>
   <title>foo.com - <%= yield(:title) %></title>
   ...
</head>
<body>
   ...
   <h1 class="heading"><%= yield(:title) %></h1>

我试图操纵标题,以添加更多的空间,并使之成为措辞之一。 我认为,如果把标题合并成一个变数,我就能够这样做。 我尝试插入&nbsp; 并且不做任何工作。 我尝试插入: html<i></i>,并且不做任何工作。 我愿谈谈这一点:

First    Second    Third

How do I change the code below to make the title look like that?

<% ttl = "First Second Third" %>
<% title ttl %>

感谢您的帮助。

最佳回答

You can have no-break spaces there, but you may need to enter them directly as characters (U+00A0).

您不能有<代码><i> tags,无论你用什么方法生成<代码><<<>>>>><<>/code>要素。

问题回答

绕行铁路越了html,同时看着,你需要用html-安全标记,以避免 escaping。

根据法典解决你的问题

<% ttl = "First &nbsp;&nbsp; Second &nbsp;&nbsp; <i>Third</i>" %>
<% title ttl.html_safe %>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签