Skip to content

Commit fdd9eb8

Browse files
committed
Merge pull request #19 from huangyq23/precision_settings
Exposed percision settings
2 parents 4229e76 + 88b623e commit fdd9eb8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/sassc/engine.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def render
2121

2222
Native.option_set_is_indented_syntax_src(native_options, true) if sass?
2323
Native.option_set_input_path(native_options, filename) if filename
24+
Native.option_set_precision(native_options, precision) if precision
2425
Native.option_set_include_path(native_options, load_paths)
2526
Native.option_set_output_style(native_options, output_style_enum)
2627
Native.option_set_source_comments(native_options, true) if line_comments?
@@ -64,6 +65,10 @@ def filename
6465
@options[:filename]
6566
end
6667

68+
def precision
69+
@options[:precision]
70+
end
71+
6772
def sass?
6873
@options[:syntax] && @options[:syntax].to_sym == :sass
6974
end

test/engine_test.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ def test_variables
6464
SCSS
6565
end
6666

67+
def test_precision
68+
template = <<-SCSS
69+
$var: 1;
70+
.foo {
71+
baz: $var / 3; }
72+
SCSS
73+
expected_output = <<-CSS
74+
.foo {
75+
baz: 0.33333333; }
76+
CSS
77+
output = Engine.new(template, precision: 8).render
78+
assert_equal expected_output, output
79+
end
80+
81+
def test_precision_not_specified
82+
template = <<-SCSS
83+
$var: 1;
84+
.foo {
85+
baz: $var / 3; }
86+
SCSS
87+
expected_output = <<-CSS
88+
.foo {
89+
baz: 0.33333; }
90+
CSS
91+
output = Engine.new(template).render
92+
assert_equal expected_output, output
93+
end
94+
6795
def test_dependency_filenames_are_reported
6896
temp_file("not_included.scss", "$size: 30px;")
6997
temp_file("import_parent.scss", "$size: 30px;")

0 commit comments

Comments
 (0)