css - Rails - Difference between @import and *= require? -


so i've got relatively simple rails app, , wanted add material design styling through bootstrap.

i've added following gems gemfile:

gem 'bootstrap-sass' gem 'bootstrap-material-design' 

now both work, question why seem have add them app in different ways. vanilla boostrap import view specific (i think that's right term) scss file normal.

@import "bootstrap-sprockets"; @import "bootstrap"; 

but material design gem have 'require' root application.css file instead

 *= require bootstrap-material-design 

why difference, , require syntax doing?

the include , require methods different things.

the require method include in other programming languages: run file. tracks you've required in past , won't require same file twice. run file without added functionality, can use load method.

the include method takes methods module , includes them current module. language-level thing opposed file-level thing require. include method primary way "extend" classes other modules (usually referred mix-ins). example, if class defines method "each", can include mixin module enumerable , can act collection. can confusing include verb used differently in other languages.

so if want use module, rather extend or mix-in, you'll want use require.

oddly enough, ruby's require analogous c's include, while ruby's include nothing c's include.

more info


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -