ruby - Setting Sass variables into Sass.compile_file -
is possible inject variables sass scope when using method sass.compile_file
?
currently i'm passing values custom:
argument, creating custom sass function, , calling within sass file/script. awkward have create objects of appropriate types return functions, i.e. sass::script::string
, rather string
.
i think according is there way can overwrite less variable less compiler in php? can open file , parse contents through (sass.compile
)[http://sass-lang.com/documentation/sass.html] instead of using sass.compile_file
directly.
with compile.rb
:
#!/usr/bin/ruby require 'sass' data = file.read("./colors.scss") puts sass::compile('$color: white;' + data)
and colors.scss
:
$color: blue !default; p { color: $color; }
running ./compile.rb
outputs:
p { color: white; }
according the docs should use sass::engine
:
using sass in ruby code simple. after installing sass gem, can use running require "sass" , using sass::engine.
#!/usr/bin/ruby require 'sass' template = file.read('./colors.scss') sass_engine = sass::engine.new("$color: white;\n" + template, :syntax => :scss) output = sass_engine.render puts output
Comments
Post a Comment