Last active
November 15, 2016 16:06
-
-
Save manuelmeurer/6399889 to your computer and use it in GitHub Desktop.
Render dynamic CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Display::WidgetsController < ApplicationController | |
| def show | |
| scss = render_to_string('show', locals: { foo: bar }, formats: :scss) | |
| @css = Sass::Engine.new(scss, Compass.sass_engine_options.merge(syntax: :scss)).render | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %style{ type: 'text/css' } | |
| = css.chomp.html_safe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| div[data-id="<%= foo %>"] { | |
| display: none; | |
| } |
you need set gems in assets group in Gemfile accessible under production environment
Author
@imports should work if you:
- make sure you're importing a partial, i.e. the filename must be
_base.css.scss, notbase.css.scss - include the full filename except
.scssin the import directive, i.e.@import "base.css";
@manuelmeurer it works, thanks you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not work for me with @import into the .scss.erb file.
Any idea ?
Thanks.