##DESCRIPTION Xass extends Rails with namespacing CSS classes in Sass. ##INSTALLATION We suppose you use Rails with sass-rails. ###Gemfile ```rb gem 'xass' ``` ##USAGE ###Example 1 ```sass // /app/assets/stylesheets/application.sass @import ./main/**/* ``` ```sass // /app/assets/stylesheets/main/hoge/piyo/fuga.sass .hogehoge width: 100px ``` This emits the following css. ```css .hoge__piyo__fuga___hogehoge { width: 100px; } ``` In view, use helpers to apply the style. ```haml -# /app/views/someview.html.haml = namespace :hoge, :piyo, :fuga do %div{ class: ns(:hogehoge) } ``` This emits ```html
``` As matter of course, `namespace` can be nested as follows. ```haml -# /app/views/someview.html.haml = namespace :hoge do = namespace :piyo do = namespace :fuga do %div{ class: ns(:hogehoge) } ``` ###Example 2 You can use `root` class for convenience. ```sass // /app/assets/stylesheets/main/hoge/piyo/fuga.sass .root width: 10px .hogehoge width: 100px ``` This emits ```css .hoge__piyo__fuga { width: 10px; } .hoge__piyo__fuga___hogehoge { width: 100px; } ``` And, ```haml -# /app/views/someview.html.haml = namespace :hoge, :piyo, :fuga do %div{ class: ns_root } %div{ class: ns(:hogehoge) } ``` This emits ```html