Class: Haml::Exec::Sass
- Defined in:
- lib/gems/haml-2.0.4/lib/haml/exec.rb
Overview
A class encapsulating executable functionality specific to Sass.
Instance Method Summary collapse
-
#initialize(args) ⇒ Sass
constructor
:nodoc:.
- #process_result ⇒ Object
- #set_opts(opts) ⇒ Object
Methods inherited from Generic
Constructor Details
#initialize(args) ⇒ Sass
:nodoc:
166 167 168 169 |
# File 'lib/gems/haml-2.0.4/lib/haml/exec.rb', line 166 def initialize(args) super @name = "Sass" end |
Instance Method Details
#process_result ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/gems/haml-2.0.4/lib/haml/exec.rb', line 180 def process_result super input = @options[:input] output = @options[:output] template = input.read() input.close() if input.is_a? File begin # We don't need to do any special handling of @options[:check_syntax] here, # because the Sass syntax checking happens alongside evaluation # and evaluation doesn't actually evaluate any code anyway. result = ::Sass::Engine.new(template, @options[:for_engine]).render rescue ::Sass::SyntaxError => e raise e if @options[:trace] raise "Syntax error on line #{get_line e}: #{e.}" end output.write(result) output.close() if output.is_a? File end |
#set_opts(opts) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/gems/haml-2.0.4/lib/haml/exec.rb', line 171 def set_opts(opts) super opts.on('-t', '--style NAME', 'Output style. Can be nested (default), compact, compressed, or expanded.') do |name| @options[:for_engine][:style] = name.to_sym end end |