Rails 3命令将我的CSS样式表的文本嵌入到HTML的头部
Heroku为使用HyPDF将HTML转换为PDF格式的用户提供以下建议 :
Place your styles and scripts within and tags instead of loading them using tag.
目前,我正在使用以下内容:
= stylesheet_link_tag "print", :media => "print, screen, projection"
什么是Rails 3.2代码生成与嵌入式非链接CSS的等价物?
(这是因为Rails会自动将/app/assets/stylesheets/print.scss
所有CSS插入到它生成的HTML中,而不是手动将所有CSS复制粘贴到content_tag
,然后必须保留其中的内容标签。)
在API文档中找不到任何内容。
谢谢。
将以下代码放在application.html.erb的head部分中应该可以正常工作:
当然,如果您要包含来自多个不同视图的样式表,则需要在application.html.erb中设置yield:
然后从每个视图:
<% content_for :inline_style %> <%= render :file => Rails.application.assets.find_asset('**stylesheet name**') %> <% end %>
或者,如果您仍想使用资产管道,请参阅如何在使用rails资产管道时内联css