Stylesheet_link_tag :all versus :media =>all

后端 未结 4 1079
面向向阳花
面向向阳花 2020-12-29 12:40

I created a new Rails application from a scaffold, but the tutorial claims the following will appear:

<%= stylesheet_link_tag    \"application\", :media =         


        
4条回答
  •  轮回少年
    2020-12-29 12:58

    stylesheet_link_tag also accepts a parameter for the media attribute in the generated

     < %= stylesheet_link_tag :media => "all" %>
    

    Will produce:

    
    

    If, instead, you want to include all the stylesheets in the stylesheets directory, just call:

    < %= stylesheet_link_tag :all %>
    

    from the rails wiki:

    Notice that stylesheet_link_tag will, by default, search for stylesheets in the /public/stylesheets directory of your application. Also, when no other parameters are passed to stylesheet_link_tag, the type attribute is set to text/css, media is set to screen, and relationship is set to stylesheet. Furthermore, you don't have to include the .css extension in the filename when passing the filename parameter. You're welcome to include it, but as long as your CSS stylesheets are named with the .css extension, there's no need to do so. Note that if you include a file extension, Rails will no longer look for a file with the .css extension for this call. For instance, if you want to include a stylesheet named my_style.new.css, the following is not sufficient:

提交回复
热议问题