Class: Sass::Engine
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
Defined Under Namespace
Classes: Line
Constant Summary collapse
- 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 collapse
-
#initialize(template, options = {}) ⇒ Engine
constructor
A new instance of Engine.
-
#render ⇒ String
(also: #to_css)
Render the template to CSS.
-
#to_tree ⇒ Sass::Tree::Node
Parses the document into its parse tree.
Methods included from Haml::Util
#ap_geq_3?, #assert_html_safe!, #av_template_class, #caller_info, #check_encoding, #def_static_method, #enum_cons, #enum_slice, #enum_with_index, #haml_warn, #has?, #html_safe, #map_hash, #map_keys, #map_vals, #merge_adjacent_strings, #ord, #powerset, #rails_env, #rails_root, #rails_safe_buffer_class, #rails_xss_safe?, #restrict, #ruby1_8?, #scope, #silence_haml_warnings, #silence_warnings, #static_method_name, #strip_string_array, #to_hash
Constructor Details
#initialize(template, options = {}) ⇒ Engine
Returns a new instance of Engine.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/sass/engine.rb', line 147
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
#render ⇒ String Also known as: to_css
Render the template to CSS.
167 168 169 170 |
# File 'lib/sass/engine.rb', line 167
def render
return _to_tree.render unless @options[:quiet]
Haml::Util.silence_haml_warnings {_to_tree.render}
end
|
#to_tree ⇒ Sass::Tree::Node
Parses the document into its parse tree.
177 178 179 180 |
# File 'lib/sass/engine.rb', line 177
def to_tree
return _to_tree unless @options[:quiet]
Haml::Util.silence_haml_warnings {_to_tree}
end
|