forked from meteor/meteor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new sass package based on less package.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Package.describe({ | ||
summary: "Sassy CSS pre-processor." | ||
}); | ||
|
||
var sass = require('sass'); | ||
var fs = require('fs'); | ||
|
||
Package.register_extension( | ||
"sass", function (bundle, source_path, serve_path, where) { | ||
serve_path = serve_path + '.css'; | ||
|
||
try { | ||
var contents = fs.readFileSync(source_path); | ||
var css = sass.render(contents.toString('utf8')); | ||
// NOTE: sass does not seem to return any sort of error. It just | ||
// silently ignores bad sass code. | ||
|
||
bundle.add_resource({ | ||
type: "css", | ||
path: serve_path, | ||
data: new Buffer(css), | ||
where: where | ||
}); | ||
} catch (e) { | ||
// Haven't been able to get sass to throw, but just in case. | ||
bundle.error(source_path + ": Sass compiler error: " + e.message); | ||
} | ||
} | ||
); | ||
|
||
Package.on_test(function (api) { | ||
api.add_files(['sass_tests.sass', 'sass_tests.js'], 'client'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Tinytest.add("sass - presence", function(test) { | ||
|
||
// find the .sass stylesheet, whose first rule contains "sass-tests" | ||
// in the selector | ||
var sheet = _.find(document.styleSheets, function(sh) { | ||
var rules = sh.cssRules || sh.rules; | ||
return /sass-tests/.test(rules[0].selectorText); | ||
}); | ||
|
||
test.isTrue(sheet); | ||
|
||
// `cssRules` is the W3C name, but isn't supported in IE until | ||
// version 9. IE<=8 has `rules`. We prefer `cssRules` as | ||
// it is less likely to have quirks if both are present. | ||
var rules = sheet.cssRules || sheet.rules; | ||
|
||
test.equal(rules[1].style.borderLeftWidth, "13px"); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#sass-tests | ||
:zoom 1 | ||
|
||
unlucky: 13px | ||
|
||
.unlucky-left-border | ||
:border-left-width !unlucky |