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
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
61 62 63 64 |
# File 'lib/sassc/engine.rb', line 61 def dependencies raise NotRenderedError unless @dependencies Dependency.from_filenames(@dependencies) end |
#filename ⇒ Object
71 72 73 |
# File 'lib/sassc/engine.rb', line 71 def filename @options[:filename] end |
#render ⇒ Object
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 |
# File 'lib/sassc/engine.rb', line 22 def render return @template.dup if @template.empty? result = ::Sass.compile_string( @template, importer: import_handler.setup(nil), load_paths: load_paths, syntax: syntax, url: file_url, charset: @options.fetch(:charset, true), source_map: || !source_map_file.nil?, source_map_include_sources: source_map_contents?, style: output_style, functions: functions_handler.setup(nil, functions: @functions), importers: @options.fetch(:importers, []), alert_ascii: @options.fetch(:alert_ascii, false), alert_color: @options.fetch(:alert_color, nil), logger: @options.fetch(:logger, nil), quiet_deps: @options.fetch(:quiet_deps, false), verbose: @options.fetch(:verbose, false) ) @dependencies = result.loaded_urls .filter { |url| url.start_with?(Protocol::FILE) && url != file_url } .map { |url| URL.file_url_to_path(url) } @source_map = post_process_source_map(result.source_map) return post_process_css(result.css) unless quiet? rescue ::Sass::CompileError => e line = e.span&.start&.line line += 1 unless line.nil? url = e.span&.url path = (URL.parse(url).route_from(URL.path_to_file_url("#{Dir.pwd}/")) if url&.start_with?(Protocol::FILE)) raise SyntaxError.new(e., filename: path, line: line) end |
#source_map ⇒ Object
66 67 68 69 |
# File 'lib/sassc/engine.rb', line 66 def source_map raise NotRenderedError unless @source_map @source_map end |