开发者

Ruby on Rails: Yield content_for Display Issues

开发者 https://www.devze.com 2023-01-09 12:44 出处:网络
Using 2.3.8 of rails. In the view template I have this type of code <%content_for :sidebar do %> <h2>Sidebar</h2>

Using 2.3.8 of rails.

In the view template I have this type of code

<%content_for :sidebar do %>
  <h2>Sidebar</h2>
  <p><%=link_to "somewhere", "http://www.google.com/"%></p>
<% end %>

<h1>Pictures#new</h1>
<p>Find me in app/views/pictures/new.html.erb</p>

In the application.html.erb template I have

<!-- END: Header -->
<%= yield(:sidebar) %>
</div>

<div class="gb">
<%= yield %>

When I go to view the page in a browser instead of showing the code correctly in named yield it is escapi开发者_C百科ng all the tags. EG;

&lt;h2&gt;Sidebar&lt;/h2&gt;
  &lt;p&gt;<a href="http://www.google.com/">somewhere</a>&lt;/p&gt;

I can't figure out what is going wrong. Help! Thanks.


I see a random </div> in your application.html.erb file--maybe that's causing the problem?

0

精彩评论

暂无评论...
验证码 换一张
取 消