What does require_self mean?

本秂侑毒 提交于 2019-11-28 17:43:26
shedd

From http://guides.rubyonrails.org/asset_pipeline.html:

/* ...
*= require_self
*= require_tree .
*/

"In this example require_self is used. This will put the CSS contained within the file (if any) at the top of any other CSS in this file unless require_self is specified after another require directive."

Shedd's answer used to be correct but now the meaning has changed ever so slightly;

Again, from http://guides.rubyonrails.org/asset_pipeline.html (bolding my own):

In this example require_self is used. This puts the CSS contained within the file (if any) at the precise location of the require_self call. If require_self is called more than once, only the last call is respected.

So you can have require_self at any point, and any CSS you have in the file will be injected into the point you wrote require_self

rafamvc
//= require_self

It loads the file itself, to define the order that the files are loaded.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!