This repository has been archived by the owner on Mar 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 157
/
index.js
53 lines (45 loc) · 1.52 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
/*jshint latedef:false */
var path = require('path');
var util = require('util');
var pascalCase = require('pascal-case');
var yeoman = require('yeoman-generator');
var scriptBase = require('../../script-base');
var ViewGenerator = scriptBase.extend({
constructor: function () {
scriptBase.apply(this, arguments);
var dirPath = this.options.coffee ? '../templates/coffeescript/' : '../templates';
this.sourceRoot(path.join(__dirname, dirPath));
},
writing: {
createViewFiles: function () {
var templateFramework = this.config.get('templateFramework') || 'lodash';
var templateExt = '.ejs';
if (templateFramework === 'mustache') {
templateExt = '-template.mustache';
} else if (templateFramework === 'handlebars') {
templateExt = '.hbs';
}
this.jst_path = this.env.options.appPath + '/scripts/templates/' + this.name + templateExt;
this.template('view.ejs', this.jst_path);
if (templateFramework === 'mustache') {
this.jst_path = this.name + '-template';
}
this._writeTemplate(
'view',
path.join(this.env.options.appPath + '/scripts/views', this.name),
{
appClassName: pascalCase(this.appname),
className: pascalCase(this.name),
'jst_path': this.jst_path
}
);
if (!this.options.requirejs) {
this._addScriptToIndex('views/' + this.name);
}
},
composeTest: function () {
this._generateTest('view');
}
}
});
module.exports = ViewGenerator;