I don't have much experience with Ruby. I want to @import sass from database instead of filesystem. I did not find any examples online. How should I go about implementing this. I see that I have to extend an importer class but since I have no understanding of ruby I need to know where in my filesystem does this class reside (Just to check it out) and in general what are the basic steps involved.
More information
MySQL database contains sass content.
So in my web application I accept sass (as string) from user which may contain an import statement for example :
@import test.scss
body { color:red }
Now in my MySQL DB I will have something like this
Table sass_files
column_name filename | content
example row test.scss | p {color:blue;}
I want to make this import work, sure I can just do a regular expression match to get the filename from the user input and then query the DB by that file name and get the content.
But I read that there is a nice way to make ruby/sass use DB as a load-path instead of filesystem.
UPDATE
SO i created a dummy custom importer class with find method as
def find(name, options)
Sass::Engine.new("p { color :blue; }", options)
end
How do i add this importer to sass load paths w/o using ruby, like can i make change to the source files in the sass gem folder and add this importer to lib/sass/importers?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…