How do I reference a .sass file from a .haml file?
I have the following haml expression that will reference a .css file:
%link{'href' => '/stylesheets/layout.css?cache=1', 'rel' => 'stylesheet', 'type' => 'text/css'}/
How do I reference a .sass file?
Sass files compile to CSS files. If you're using Rails, this is done automatically; otherwise, you can use the sass command-line executable. Check out the Sass documentation for more information.
Once you've compiled your Sass files to CSS, you reference the CSS file just like you normally do.
try using the stylesheet_link_tag method
stylesheet_link_tag "layout"
Related
I have a .css file in
vendor/assets/stylesheets/myfile.min.css
I am trying to refer to that file from my main.css.scss file
#import 'myfile.min.css';
This works on localhost but not on staging.
On my application.rb I have
config.sass.load_paths << Rails.root.join("vendor","assets","stylesheets");
But the file is not been found on staging.
As far as I'm aware, you can't import regular CSS files with Ruby's SASS implementation. I follow Node's SASS implementation more closely, and they just recently tried to disable this functionality stating it doesn't align with the SASS spec.
You should look into Rails' asset pipeline. You would add something like this to the top of your main.css.scss
//= require myfile.min
This puts the import burden on Sprockets, leaving SASS to do it's own thing afterward.
Rails comes with SASS included, but generated files come with .scss extension. I want to use indented version of SASS. Should I just rename .scss extension to .sass and that will do the trick? or should I do some extra dances to make it work?
I have some stylesheets in a subfolder /app/assets/stylesheets/themes of my rails app. These assets have the file extension .css.scss extension.
In my development environment I've been addressing those files with:
asset_path 'themes/theme-name.css.scss'
However, when I go to production Rails won't find those files. When I use just .css extension it seems to be working okay:
asset_path 'theme/theme-name.css'
My question is: what is the correct way to address asset files with multiple extensions?
Thanks for help
The correct way should be:
stylesheet_link_tag 'themes/theme-name'
If Rails is configured correct, the assets pipeline will figure out the file extensions itself .
Do you have sass loaded in your Gemfile?
I am trying to use the rails 3.1 asset pipeline to include a javascript file from the manifest file's parent directory
app/assets/javascripts/folder/index.js
//=require ../file
yields: couldn't find file 'file'
How do I require a file from the parent directory?
Assets in Sprockets are always referenced by their logical path.
So you just have to use //=require file if your file is in /app/assets/javascripts.
If your file was /lib/assets/javascripts/models/lala.js for instance, you would require it with //=require models/lala.
I have forked a rails project and found that is uses SASS, I want to remove SASS and write my css by hand.
Can i just delete the folder:public/stylesheets/sass? Remove the gem from the gemfiles, and then continue with the .css files that sass has generated?
Since there is already generated SASS, the method you suggest is the best. You do not want the SASS files overwriting your CSS.
The files with .css extension have no treated by gem sass, you can write your .css file think to change stylesheet_link_tag in layout for load your .css