Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SASS: Invalid @import: expected end of line, was ";" - sometimes

Tags:

sass

I've got a sass file that only contains import statements

@import "this";
@import "that";

if I run sass from the command line everything's good

bundle exec sass foo.scss:foo.css

If, however I run it from within a script (also via bundle exec) it gets upset about those semicolons. This...

template = File.read("foundation.scss")
sass_engine = Sass::Engine.new(template)
sass_output = sass_engine.render

...produces the following on the sass_engine.render call:

(sass):1: Invalid @import: expected end of line, was ";". (Sass::SyntaxError)

if i get rid of the semicolons then the situation is reversed. It complains on the command line and not in the script.

What's going on, and how do I get it to accept the semicolons when run from a script?

like image 784
masukomi Avatar asked Dec 17 '11 13:12

masukomi


1 Answers

The difference is that the Sass command line program notices the "scss" extension and parses the file as SCSS instead of traditional Sass. When doing it programatically, you are starting a Sass engine and not telling it that it is SCSS instead.

So, the error is that its reading it as Sass instead of SCSS.

http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options

This should fix your problem right up!

template = File.read("foundation.scss")
sass_engine = Sass::Engine.new(template, :syntax => :scss)
sass_output = sass_engine.render

Viola!

like image 67
hcatlin Avatar answered Oct 03 '22 00:10

hcatlin