作者:别禳莴觞芯_737 | 来源:互联网 | 2023-09-01 11:34
Ihavearailsappwhichusesalayout我有一个使用布局的rails应用程序Thesimplifiedversionlookslikethis:简
I have a rails app which uses a layout
我有一个使用布局的rails应用程序
The simplified version looks like this:
简化版本如下所示:
<%= render 'layouts/head' # renders the "layouts/_head.html.erb" partial correctly
# the most head (css/js) content gets implemented here %>
<%= yield # renders the current action %>
<%= content_for :scripts_bottom %>
in my `layouts/_head.html.erb' I use
在我的'layouts / _head.html.erb'我用
<%= content_for :scripts_head %>
In my partials
I place the following snippets to append them :scripts_head. (some of my partials should put Javascripts
在我的部分内容中,我将以下片段附加到它们:scripts_head。 (我的部分内容应该放在Javascripts中
<% content_for :scripts_head do %>
<%= Javascript_include_tag 'some_script' %>
<% end %>
The content_for in the `layouts/head' renders nothing
`layouts / head'中的content_for没有任何内容
How can I resolve that?
我怎么解决这个问题?
It looks like that partials
are not able to append their content_for content when the content_for :blah do
is placed BEHIND the echoing content_for / yield tag.
当content_for:blah do放置在echoing content_for / yield标记之后,看起来部分无法附加其content_for内容。
If I try try content_for :scripts_bottom
it will get rendered at the bottom of the page.
如果我尝试尝试content_for:scripts_bottom,它将在页面底部呈现。
Thanks in advance
提前致谢
Rails 3.2.14 ruby 2.0.0p247
Rails 3.2.14 ruby 2.0.0p247
3 个解决方案