forked from webark/ember-component-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpod-style.js
40 lines (34 loc) · 1.11 KB
/
pod-style.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* eslint-env node */
'use strict';
var Filter = require('broccoli-persistent-filter');
var componentNames = require('./component-names.js');
var processStratagies = require('./preprocess-class-names');
var path = require('path');
module.exports = PodStyles;
PodStyles.prototype = Object.create(Filter.prototype);
PodStyles.prototype.constructor = PodStyles;
function PodStyles(inputTree, options) {
options = options || {};
Filter.call(this, inputTree, {
annotation: options.annotation
});
this.extensions = options.extensions;
this.classicStyleDir = options.classicStyleDir;
this.terseClassNames = options.terseClassNames;
}
PodStyles.prototype.processString = function(contents, stylePath) {
var extension = path.extname(stylePath),
className = componentNames.class(stylePath, this.classicStyleDir, this.terseClassNames),
strategy = 'default';
switch (extension) {
case '.styl':
case '.sass':
strategy = 'indentation';
break;
case '.less':
case '.scss':
strategy = 'syntax';
break;
}
return processStratagies[strategy](contents, className, extension);
};