Class: Sass::Engine
- Inherits:
-
Object
- Object
- Sass::Engine
- Includes:
- Haml::Util
- Defined in:
- /var/www/haml-pages/.haml/lib/sass/engine.rb
Overview
This class handles the parsing and compilation of the Sass template. Example usage:
template = File.load('stylesheets/sassy.sass')
sass_engine = Sass::Engine.new(template)
output = sass_engine.render
puts output
Constant Summary
- DEFAULT_OPTIONS = The default options for Sass::Engine.
{ :style => :nested, :load_paths => ['.'], :cache => true, :cache_location => './.sass-cache', :syntax => :sass, }.freeze
Constants included from Haml::Util
Instance Method Summary
- - (Engine) initialize(template, options = {}) constructor A new instance of Engine.
- - (String) render (also: #to_css) Render the template to CSS.
-
- (Encoding?) source_encoding
Returns the original encoding of the document, or
nilunder Ruby 1.8. - - (Sass::Tree::Node) to_tree Parses the document into its parse tree.
Methods included from Haml::Util
#ap_geq?, #ap_geq_3?, #assert_html_safe!, #av_template_class, #caller_info, #check_encoding, #check_haml_encoding, #check_sass_encoding, #def_static_method, #enum_cons, #enum_slice, #enum_with_index, #flatten, #haml_warn, #has?, #html_safe, #intersperse, #lcs, #map_hash, #map_keys, #map_vals, #merge_adjacent_strings, #ord, #paths, #powerset, #rails_env, #rails_root, #rails_safe_buffer_class, #rails_xss_safe?, #restrict, #ruby1_8?, #ruby1_8_6?, #scope, #set_eql?, #set_hash, #silence_haml_warnings, #silence_warnings, #static_method_name, #strip_string_array, #substitute, #to_hash, #version_geq, #version_gt, #windows?
Constructor Details
- (Engine) initialize(template, options = {})
A new instance of Engine
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File '/var/www/haml-pages/.haml/lib/sass/engine.rb', line 143
def initialize(template, options={})
@options = DEFAULT_OPTIONS.merge(options.reject {|k, v| v.nil?})
@template = template
# Support both, because the docs said one and the other actually worked
# for quite a long time.
@options[:line_comments] ||= @options[:line_numbers]
# Backwards compatibility
@options[:property_syntax] ||= @options[:attribute_syntax]
case @options[:property_syntax]
when :alternate; @options[:property_syntax] = :new
when :normal; @options[:property_syntax] = :old
end
end
|
Instance Method Details
- (String) render Also known as: to_css
Render the template to CSS.
166 167 168 169 |
# File '/var/www/haml-pages/.haml/lib/sass/engine.rb', line 166
def render
return _render unless @options[:quiet]
Haml::Util.silence_haml_warnings {_render}
end
|
- (Encoding?) source_encoding
Returns the original encoding of the document, or nil under Ruby 1.8.
188 189 190 191 |
# File '/var/www/haml-pages/.haml/lib/sass/engine.rb', line 188
def source_encoding
check_encoding!
@original_encoding
end
|
- (Sass::Tree::Node) to_tree
Parses the document into its parse tree.
176 177 178 179 |
# File '/var/www/haml-pages/.haml/lib/sass/engine.rb', line 176
def to_tree
return _to_tree unless @options[:quiet]
Haml::Util.silence_haml_warnings {_to_tree}
end
|