Module: Sass
- Defined in:
- lib/sassmagic/reset.rb,
lib/sassmagic/remote.rb
Overview
重写编译
Defined Under Namespace
Class Attribute Summary collapse
Class Method Summary collapse
-
.compile(contents, options = {}) ⇒ Object
Compile a Sass or SCSS string to CSS.
-
.compile_file(filename, *args) ⇒ Object
Compile a file on disk to CSS.
-
.load_paths ⇒ Array<String, Pathname, Sass::Importers::Base>
The global load paths for Sass files.
Class Attribute Details
.tests_running ⇒ Object
69 70 71 |
# File 'lib/sassmagic/reset.rb', line 69 def tests_running @tests_running end |
Class Method Details
.compile(contents, options = {}) ⇒ Object
Compile a Sass or SCSS string to CSS. Defaults to SCSS.
107 108 109 110 |
# File 'lib/sassmagic/reset.rb', line 107 def self.compile(contents, = {}) [:syntax] ||= :scss Engine.new(contents, ).to_css end |
.compile_file(filename, options = {}) ⇒ String .compile_file(filename, css_filename, options = {}) ⇒ Object
Compile a file on disk to CSS.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/sassmagic/reset.rb', line 134 def self.compile_file(filename, *args) # debugger # puts filename # puts args # Sass.logger(filename, args) ctx = Sass::Script::Functions::EvaluationContext.new(Sass::Environment.new(nil, {})) # print 'star compile file:' #加载json # 获取设置 $configHash = ctx.load_json(File.("#{File.dirname(filename)}/../config/sassmagic.json")) || {} # puts $configHash = args.last.is_a?(Hash) ? args.pop : {} = .merge $configHash css_filename = args.shift #是否写入loadpath # debugger if (.has_key?"remoteStylesheet") && (["remoteStylesheet"] != '') RemoteSass.location = ["remoteStylesheet"] end # # debugger #是否需要额外输出样式表 if .has_key?"outputExtra" ["outputExtra"] ||= [] ["outputExtra"].each {|v| extra_filename = css_filename + '' #替换成1x 2x 3x extra_filename.gsub!(/\.css$/ , '.'+v+'.css') if extra_filename [:css_filename] = extra_filename ["multiple"] = v result = Sass::Engine.for_file(filename, ).render # open(css_filename, "w") {|css_file| css_file.write(result)} File.open(extra_filename, 'w') {|css_file| css_file.write(result)} nil else result = Sass::Engine.for_file(filename, ).render result end } end .delete("multiple") # debugger result = Sass::Engine.for_file(filename, ).render if css_filename [:css_filename] ||= css_filename open(css_filename, "w") {|css_file| css_file.write(result)} nil else result end end |
.load_paths ⇒ Array<String, Pathname, Sass::Importers::Base>
The global load paths for Sass files. This is meant for plugins and libraries to register the paths to their Sass stylesheets to that they may be ‘@imported`. This load path is used by every instance of Engine. They are lower-precedence than any load paths passed in via the `:load_paths` option.
If the ‘SASS_PATH` environment variable is set, the initial value of `load_paths` will be initialized based on that. The variable should be a colon-separated list of path names (semicolon-separated on Windows).
Note that files on the global load path are never compiled to CSS themselves, even if they aren’t partials. They exist only to be imported.
89 90 91 92 93 94 95 |
# File 'lib/sassmagic/reset.rb', line 89 def self.load_paths @load_paths ||= if ENV['SASS_PATH'] ENV['SASS_PATH'].split(Sass::Util.windows? ? ';' : ':') else [] end end |