Class: Sass::Engine
Overview
This is the class where all the parsing and processing of the Sass template is done. It can be directly used by the user by creating a new instance and calling render
to render the template. For example:
template = File.load('stylesheets/sassy.sass')
sass_engine = Sass::Engine.new(template)
output = sass_engine.render
puts output
Constant Summary collapse
- ATTRIBUTE_CHAR =
The character that begins a CSS attribute.
?:
- SCRIPT_CHAR =
The character that designates that an attribute should be assigned to the result of constant arithmetic.
?=
- 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
?+
- ATTRIBUTE =
The regex that matches and extracts data from attributes of the form
:name attr
. /^:([^\s=:]+)\s*(=?)(?:\s+|$)(.*)/
- ATTRIBUTE_ALTERNATE_MATCHER =
The regex that matches attributes of the form
name: attr
. /^[^\s:]+\s*[=:](\s|$)/
- ATTRIBUTE_ALTERNATE =
The regex that matches and extracts data from attributes of the form
name: attr
. /^([^\s=:]+)(\s*=|:)(?:\s+|$)(.*)/
Instance Method Summary collapse
-
#initialize(template, options = {}) ⇒ Engine
constructor
Creates a new instace of Sass::Engine that will compile the given template string when
render
is called. -
#render ⇒ Object
(also: #to_css)
Processes the template and returns the result as a string.
Constructor Details
#initialize(template, options = {}) ⇒ Engine
Creates a new instace of Sass::Engine that will compile the given template string when render
is called. See README.rdoc for available options.
–
TODO: Add current options to REFRENCE. Remember :filename!
When adding options, remember to add information about them to README.rdoc! ++
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/gems/haml-2.0.4/lib/sass/engine.rb', line 74 def initialize(template, ={}) @options = { :style => :nested, :load_paths => ['.'] }.merge! @template = template.split(/\r\n|\r|\n/) @lines = [] @constants = {"important" => "!important"} @mixins = {} end |
Instance Method Details
#render ⇒ Object Also known as: to_css
Processes the template and returns the result as a string.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/gems/haml-2.0.4/lib/sass/engine.rb', line 86 def render begin render_to_tree.to_s rescue SyntaxError => err unless err.sass_filename err.add_backtrace_entry(@options[:filename]) end raise err end end |