开发者

Rails Routing INSIDE CSS

开发者 https://www.devze.com 2022-12-31 05:33 出处:网络
Is there any way I can route assets inside of my css to where therest of the views are pulling them? I mean, inside the CSS can I call url_for or css_for or something like that in order to 开发者_开发

Is there any way I can route assets inside of my css to where the rest of the views are pulling them? I mean, inside the CSS can I call url_for or css_for or something like that in order to 开发者_开发问答have the images go through the assets router?

Thank you in advance!


You can use a controller action to render your CSS (with an erb template) and set the content type to text/css.

Take a look at this blog post from Josh Susser on dynamically generated stylesheets. It is from 2006 but the technique described is still applicable.

0

精彩评论

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