Class: SassC::Engine
- Inherits:
-
Object
- Object
- SassC::Engine
- Defined in:
- lib/sassc/engine.rb
Constant Summary collapse
- OUTPUT_STYLES =
%i[ sass_style_nested sass_style_expanded sass_style_compact sass_style_compressed ]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #dependencies ⇒ Object
- #filename ⇒ Object
-
#initialize(template, options = {}) ⇒ Engine
constructor
A new instance of Engine.
- #render ⇒ Object
- #source_map ⇒ Object
Constructor Details
#initialize(template, options = {}) ⇒ Engine
Returns a new instance of Engine.
16 17 18 19 |
# File 'lib/sassc/engine.rb', line 16 def initialize(template, = {}) @template = template @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/sassc/engine.rb', line 14 def @options end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
14 15 16 |
# File 'lib/sassc/engine.rb', line 14 def template @template end |
Instance Method Details
#dependencies ⇒ Object
64 65 66 67 |
# File 'lib/sassc/engine.rb', line 64 def dependencies raise NotRenderedError unless @dependencies Dependency.from_filenames(@dependencies) end |
#filename ⇒ Object
74 75 76 |
# File 'lib/sassc/engine.rb', line 74 def filename @options[:filename] end |
#render ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sassc/engine.rb', line 21 def render return @template.dup if @template.empty? data_context = Native.make_data_context(@template) context = Native.data_context_get_context(data_context) = Native.(context) Native.option_set_is_indented_syntax_src(, true) if sass? Native.option_set_input_path(, filename) if filename Native.option_set_precision(, precision) if precision Native.option_set_include_path(, load_paths) Native.option_set_output_style(, output_style_enum) Native.option_set_source_comments(, true) if line_comments? Native.option_set_source_map_file(, source_map_file) if source_map_file Native.(, true) if Native.option_set_source_map_contents(, true) if source_map_contents? Native.option_set_omit_source_map_url(, true) if omit_source_map_url? import_handler.setup() functions_handler.setup() status = Native.compile_data_context(data_context) if status != 0 = Native.(context) filename = Native.context_get_error_file(context) line = Native.context_get_error_line(context) raise SyntaxError.new(, filename: filename, line: line) end css = Native.context_get_output_string(context) @dependencies = Native.context_get_included_files(context) @source_map = Native.context_get_source_map_string(context) Native.delete_data_context(data_context) css.force_encoding(@template.encoding) return css unless quiet? end |
#source_map ⇒ Object
69 70 71 72 |
# File 'lib/sassc/engine.rb', line 69 def source_map raise NotRenderedError unless @source_map @source_map end |