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
63
64
|
# File 'lib/sassc/engine.rb', line 22
def render
return @template.dup if @template.empty?
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_precision(native_options, precision) if precision
Native.option_set_include_path(native_options, load_paths)
Native.option_set_output_style(native_options, output_style_enum)
Native.(native_options, true) if
Native.option_set_source_map_file(native_options, source_map_file) if source_map_file
Native.option_set_source_map_embed(native_options, true) if source_map_embed?
Native.option_set_source_map_contents(native_options, true) if source_map_contents?
Native.option_set_omit_source_map_url(native_options, true) if omit_source_map_url?
import_handler.setup(native_options)
functions_handler.setup(native_options, functions: @functions)
status = Native.compile_data_context(data_context)
if status != 0
message = Native.context_get_error_message(context)
filename = Native.context_get_error_file(context)
line = Native.context_get_error_line(context)
raise SyntaxError.new(message, 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)
css.force_encoding(@template.encoding)
@source_map.force_encoding(@template.encoding) if @source_map.is_a?(String)
return css unless quiet?
ensure
Native.delete_data_context(data_context) if data_context
end
|