This repository has been archived by the owner on Sep 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGruntfile.js
97 lines (83 loc) · 2.66 KB
/
Gruntfile.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict';
//An example gruntfile that shows
//Common uses of grunt-hogan
//https://github.com/automatonic/grunt-hogan
module.exports = function(grunt) {
//Standard grunt init
grunt.initConfig({
//configure a grunt-hogan task
hogan: {
//grunt-hogan is a "multitarget" task
//so each key is a new, arbitrarily-named target
//the 'simple' target compiles the src template
//into the destination file
simple : {
src: './view/simple.html',
dest: './tmp/simple.js'
},
//the 'glob' target compiles template files matched by the glob
//into the destination file
glob: {
src : './view/multi*.html',
dest : './tmp/glob.js'
},
//the 'glob' target compiles template files matched by the glob
//into the destination file
multi: {
src : ['./view/multi1.html', './view/multi2.html', './view/multi3.html'],
dest : './tmp/multi.js'
},
//use the 'revealing' binder
//(resulting template javascript will follow the 'revealing
// module pattern')
use_revealing: {
src : './view/multi*.html',
dest : './tmp/use_revealing.js',
options: { binderName: 'revealing' }
},
//use the 'amd' binder
//(resulting template javascript will follow the 'abstract
// module definition')
use_amd : {
src : './view/multi*.html',
dest : './tmp/use_amd.js',
options: { binderName: 'amd' }
},
//the 'namefunc' target will compile
//the multi templates giving each a custom
//name via nameFunc
namefunc : {
src : './view/multi*.html',
dest : './tmp/namefunc.js',
options: {
binderName: 'hulk',
//Specify a custom name function
nameFunc: function(fileName) {
//Grab the path package here locally for clarity
var _path = require('path');
//'yada/yada/multi1.html' -> 'multi1'
var name = _path
.basename(
fileName,
_path.extname(fileName));
//'multi1' -> 'name_1'
return 'name_'+name[5];
}
}
}
},
//clean our compiled templates
clean: {
all: ['tmp']
}
});
//Load the grunt-hogan plugin!
grunt.loadNpmTasks('grunt-hogan');
//And the clean
grunt.loadNpmTasks('grunt-contrib-clean');
//Just clean and run all hogan targets
//For custom binder examples, see
//Gruntfile.custombinder.js and
//Gruntfile.twocustombinders.js
grunt.registerTask('default', ['clean', 'hogan']);
};