-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
64 lines (50 loc) · 1.89 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* jshint node: true */
'use strict';
var path = require('path');
var checker = require('ember-cli-version-checker');
var rawHandlebarsCompiler = require('./raw-handlebars-compiler');
var mergeTrees = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');
module.exports = {
name: 'ember-cli-raw-handlebars',
init: function() {
checker.assertAbove(this, '0.1.2');
},
included: function(app) {
app.import(this.templateRuntimePath());
},
projectConfig: function() {
return this.project.config(process.env.EMBER_ENV);
},
rawTemplatesPath: function() {
return this.app.options.rawTemplatesPath || path.join(this.app.trees.app, 'raw-templates');
},
treeForApp: function(tree) {
var rawTemplates = mergeTrees([this.rawTemplatesPath()]);
rawTemplates = new Funnel(rawTemplates, { destDir: 'raw-templates' });
rawTemplates = this.processRawTemplates(rawTemplates);
return this.mergeTrees([tree, rawTemplates]);
},
processRawTemplates: function(tree) {
var options = {
templateCompilerPath: this.templateCompilerPath()
};
return rawHandlebarsCompiler(tree, options);
},
templateCompilerPath: function() {
var config = this.projectConfig();
var templateCompilerPath = config['ember-cli-raw-handlebars'] && config['ember-cli-raw-handlebars'].templateCompilerPath;
if (!templateCompilerPath) {
templateCompilerPath = this.project.bowerDirectory + '/handlebars/handlebars';
}
return path.join(this.project.root, templateCompilerPath);
},
templateRuntimePath: function() {
var config = this.projectConfig();
var templateRuntimePath = config['ember-cli-raw-handlebars'] && config['ember-cli-raw-handlebars'].templateRuntimePath;
if (!templateRuntimePath) {
templateRuntimePath = this.project.bowerDirectory + '/handlebars/handlebars.runtime.js';
}
return templateRuntimePath;
}
};