Class: Sass::Engine
Overview
Defined Under Namespace
Classes: Line
Constant Summary collapse
- PROPERTY_CHAR =
The character that begins a CSS property.
?:
- SCRIPT_CHAR =
The character that designates that a property should be assigned to a SassScript expression.
?=
- COMMENT_CHAR =
The character that designates the beginning of a comment, either Sass or CSS.
?/
- SASS_COMMENT_CHAR =
The character that follows the general COMMENT_CHAR and designates a Sass comment, which is not output as a CSS comment.
?/
- CSS_COMMENT_CHAR =
The character that follows the general COMMENT_CHAR and designates a CSS comment, which is embedded in the CSS document.
?*
- DIRECTIVE_CHAR =
The character used to denote a compiler directive.
?@
- ESCAPE_CHAR =
Designates a non-parsed rule.
?\\
- MIXIN_DEFINITION_CHAR =
Designates block as mixin definition rather than CSS rules to output
?=
- MIXIN_INCLUDE_CHAR =
Includes named mixin declared using MIXIN_DEFINITION_CHAR
?+
- PROPERTY_NEW_MATCHER =
The regex that matches properties of the form
name: prop
. /^[^\s:"]+\s*[=:](\s|$)/
- PROPERTY_NEW =
The regex that matches and extracts data from properties of the form
name: prop
. /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/
- PROPERTY_OLD =
The regex that matches and extracts data from properties of the form
:name prop
. /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
- DEFAULT_OPTIONS =
The default options for Sass::Engine.
{ :style => :nested, :load_paths => ['.'], :cache => true, :cache_location => './.sass-cache', }.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
#def_static_method, #enum_with_index, #has?, #map_hash, #map_keys, #map_vals, #merge_adjacent_strings, #powerset, #ruby1_8?, #scope, #static_method_name, #to_hash
Constructor Details
#initialize(template, options = {}) ⇒ Engine
Returns a new instance of Engine.
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/sass/engine.rb', line 131 def initialize(template, ={}) @options = DEFAULT_OPTIONS.merge() @template = template # 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.
147 148 149 |
# File 'lib/sass/engine.rb', line 147 def render to_tree.render end |
#to_tree ⇒ Sass::Tree::Node
Parses the document into its parse tree.
157 158 159 160 161 162 163 |
# File 'lib/sass/engine.rb', line 157 def to_tree root = Tree::Node.new append_children(root, tree(tabulate(@template)).first, true) root. = @options root rescue SyntaxError => e; e.(@options[:filename], @line) end |