Class: SassC::Engine

Inherits:
Object
  • Object
show all
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 Method Summary collapse

Constructor Details

#initialize(template, options = {}) ⇒ Engine

Returns a new instance of Engine.



12
13
14
15
# File 'lib/sassc/engine.rb', line 12

def initialize(template, options = {})
  @template = template
  @options = options
end

Instance Method Details

#dependenciesObject

Raises:



46
47
48
49
# File 'lib/sassc/engine.rb', line 46

def dependencies
  raise NotRenderedError unless @dependencies
  Dependency.from_filenames(@dependencies)
end

#renderObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sassc/engine.rb', line 17

def render
  data_context = Native.make_data_context(@template)
  context = Native.data_context_get_context(data_context)
  native_options = Native.context_get_options(context)

  Native.option_set_is_indented_syntax_src(native_options, true) if sass?
  Native.option_set_input_path(native_options, filename) if filename
  Native.option_set_include_path(native_options, load_paths)
  Native.option_set_output_style(native_options, output_style_enum)

  import_handler.setup(native_options)
  functions_handler.setup(native_options)

  status = Native.compile_data_context(data_context)

  if status != 0
    message = Native.context_get_error_message(context)
    raise SyntaxError.new(message)
  end

  css = Native.context_get_output_string(context)

  @dependencies = Native.context_get_included_files(context)

  Native.delete_data_context(data_context)

  return css unless quiet?
end