User theme switching with SASS - Ruby on Rails

后端 未结 4 534
执笔经年
执笔经年 2021-02-04 13:45

So I have an rails admin system that will allow a user to choose a theme, basically a set of SASS color variables that will recompile application.css.scss with the new colors. H

4条回答
  •  我在风中等你
    2021-02-04 14:05

    I believe that you could use erb to inline variables in sass. I'm not positive, but I think it would look something like this:

    themes/_whatever_theme.sass.erb

    $theme_sprite_path: '<%= Theme.sprite_path %>';
    $main_color: <%= Theme.main_color %>;
    $secondary_color: <%= Theme.secondary_color %>;
    

    These should be created dynamically for each page load. I'm not sure how the caching would work here.

提交回复
热议问题