-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
841 lines (773 loc) · 23.2 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
'use strict';
var os = require('os');
var _ = require('underscore');
var _s = require('underscore.string');
var modRewrite = require('connect-modrewrite');
var Handlebars = require('handlebars');
//////////////////////////////
// Handlebars Helpers for component templating
//////////////////////////////
Handlebars.registerHelper('slugify', function(input) {
return _s.slugify(input);
});
Handlebars.registerHelper('capitalize', function(input) {
return _s.capitalize(input);
});
Handlebars.registerHelper('flatten', function (input, separator) {
if (typeof(input) === 'object') {
input = Array.prototype.slice.call(input);
if (separator !== 'space') {
return input.join(', ');
}
else {
return input.join(' ');
}
}
else {
return input;
}
});
module.exports = function (grunt) {
//////////////////////////////
// Import Grunt Configuration
//
// Combine with System options
//////////////////////////////
var deepmerge = require('deepmerge');
var userConfig = grunt.file.readYAML('config.yml');
userConfig = deepmerge(userConfig, grunt.file.readJSON('.system.json'));
userConfig = deepmerge(userConfig, grunt.file.readJSON('.extension.json'));
grunt.userConfig = userConfig;
// Slugs and Stuff
grunt.userConfig.clientSlug = _s.slugify(userConfig.client.name);
grunt.userConfig.clientCamelCase = _s.camelize(grunt.userConfig.clientSlug);
grunt.userConfig.clientCamelCase = grunt.userConfig.clientCamelCase.charAt(0).toUpperCase() + grunt.userConfig.clientCamelCase.slice(1);
// Asset Paths
var imagesDir = userConfig.assets.imagesDir;
var cssDir = userConfig.assets.cssDir;
var sassDir = userConfig.assets.sassDir;
var jsDir = userConfig.assets.jsDir;
var fontsDir = userConfig.assets.fontsDir;
var componentsDir = userConfig.assets.componentsDir;
// Generator Configuration
var pagesDir = userConfig.generator.pagesDir;
var templatesDir = userConfig.generator.templatesDir;
var partialsDir = userConfig.generator.partialsDir;
var helpers = userConfig.generator.helpers;
helpers = require('./' + helpers);
// Server Configuration
var port = userConfig.server.port;
var lrport = port + 1;
var wnport = port + 2;
var root = userConfig.server.root;
var hostname = 'localhost';
var remoteDebug = false;
if (userConfig.server.remoteAccess) {
hostname = '*';
remoteDebug = true;
}
var remoteHost = os.networkInterfaces();
for (var dev in remoteHost) {
var alias = 0;
remoteHost[dev].forEach(function (details) {
if (details.family=='IPv4') {
if (dev === 'en0') {
remoteHost = details.address;
}
}
});
};
var firstSection = userConfig.sections;
for (var a in firstSection) {
if (typeof(firstSection[a]) === 'string') {
firstSection = firstSection[a];
if (firstSection.indexOf('.html', firstSection.length - 5) === -1) {
firstSection += '/';
}
break;
}
break;
}
// Compass Configuration
var debugInfo = userConfig.compass.debugInfo;
var extensions = [];
_.forEach(userConfig.compass.dependencies, function(v, e) {
extensions.push(e);
});
// Export Configuration
var distPath = userConfig.export.distPath;
var exportPath = userConfig.export.path;
var assetPrefix = userConfig.export.assetPrefix;
// Github Configuration
var gh_commit = userConfig.git.defaultCommit;
var gh_upstream = userConfig.git.deployUpstream;
var gh_deploy = userConfig.git.deployBranch;
//////////////////////////////
//Grunt Config
//////////////////////////////
grunt.initConfig({
// Development Server
connect: {
server: {
options: {
port: port,
base: root,
hostname: hostname,
middleware: function (connect, options) {
return [
modRewrite([
'^/$ /' + firstSection
]),
connect.static(options.base)
];
}
}
}
},
// Watch Task
watch: {
options: {
livereload: lrport
},
html: {
files: [
pagesDir + '/**/*.html',
pagesDir + '/**/*.md',
pagesDir + '/**/*.yml',
partialsDir + '/**/*.html',
templatesDir + '/**/*.html',
'!' + templatesDir + '/components/**/*.html',
helpers + '.js'
],
tasks: ['generator:dev']
},
generatedComponents: {
files: [
templatesDir + '/components/**/*.html',
'config.yml'
],
tasks: ['create-components']
},
js: {
files: [
jsDir + '/**/*.js',
'!' + jsDir + '/**/*.min.js'
],
tasks: ['jshint', 'uglify:dev']
},
images: {
files: [imagesDir + '/**/*'],
tasks: ['copy:dev']
},
fonts: {
files: [fontsDir + '/**/*'],
tasks: ['copy:dev']
},
components: {
files: [componentsDir + '/**/*'],
tasks: ['copy:dev']
},
css: {
files: [root + '/' + cssDir + '/**/*.css'],
tasks: ['csslint']
},
config: {
files: [
'config.yml',
'.system.yml'
],
tasks: ['generator:dev']
}
},
// Generator Task
generator: {
dev: {
files: [{
cwd: pagesDir,
src: ['**/*'],
dest: root,
ext: '.html'
}],
options: {
partialsGlob: [partialsDir + '/**/*.html', partialsDir + '/**/*.md'],
templates: templatesDir,
handlebarsHelpers: helpers,
userConfig: userConfig,
environment: 'dev',
development: true,
lrport: lrport,
wnport: wnport,
remoteDebug: remoteDebug,
assets: ''
}
},
dist: {
files: [{
cwd: pagesDir,
src: ['**/*'],
dest: distPath,
ext: '.html'
}],
options: {
partialsGlob: [partialsDir + '/**/*.html', partialsDir + '/**/*.md'],
templates: templatesDir,
handlebarsHelpers: helpers,
userConfig: userConfig,
environment: 'prod',
development: false,
assets: '/' + assetPrefix
}
}
},
// Compass Task
compass: {
options: {
sassDir: sassDir,
require: extensions,
relativeAssets: true,
importPath: componentsDir,
debugInfo: debugInfo,
bundleExec: true
},
dev: {
options: {
imagesDir: root + '/' + imagesDir,
cssDir: root + '/' + cssDir,
javascriptsDir: root + '/' + jsDir,
fontsDir: root + '/' + fontsDir,
environment: 'development',
watch: true
}
},
dist: {
options: {
imagesDir: distPath + '/' + imagesDir,
cssDir: distPath + '/' + cssDir,
javascriptsDir: distPath + '/' + jsDir,
fontsDir: distPath + '/' + fontsDir,
environment: 'production',
force: true
}
}
},
// JSHint Task
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
jsDir + '/{,**/}*.js',
'!' + jsDir + '/{,**/}*.min.js'
]
},
// CSS Lint
csslint: {
options: {
csslintrc: '.csslintrc'
},
all: [
root + '/' + cssDir + '/{,**/}*.css'
]
},
// Image Min Task
imagemin: {
dist: {
options: {
optimizationLevel: 3
},
files: [{
expand: true,
cwd: imagesDir,
src: ['**/*.png', '**/*.jpg'],
dest: distPath + '/' + imagesDir
}]
}
},
// SVG Min Task
svgmin: {
dist: {
files: [{
expand: true,
cwd: imagesDir,
src: '**/*.svg',
dest: distPath + '/' + imagesDir
}]
}
},
// Uglify Task
uglify: {
dev: {
options: {
mangle: false,
compress: false,
beautify: true
},
files: [{
expand: true,
cwd: jsDir,
src: ['**/*.js', '!**/*.min.js'],
dest: root + '/' + jsDir,
ext: '.js'
}]
},
dist: {
options: {
mangle: true,
compress: true
},
files: [{
expand: true,
cwd: jsDir,
src: ['**/*.js', '!**/*.min.js'],
dest: distPath + '/' + jsDir,
ext: '.js'
}]
}
},
// Copy Task
copy: {
dev: {
files: [
{
expand: true,
cwd: fontsDir,
src: ['**'],
dest: root + '/' + fontsDir
},
{
expand: true,
cwd: imagesDir,
src: ['**'],
dest: root + '/' + imagesDir
},
{
expand: true,
cwd: componentsDir,
src: ['**'],
dest: root + '/' + componentsDir
}
]
},
dist: {
files: [
{
expand: true,
cwd: fontsDir,
src: ['**'],
dest: distPath + '/' + fontsDir
},
{
expand: true,
cwd: imagesDir,
src: [
'**',
'!**/*.png',
'!**/*.jpg',
'!**/*.svg'
],
dest: distPath + '/' + imagesDir
},
{
expand: true,
cwd: componentsDir,
src: ['**'],
dest: distPath + '/' + componentsDir
}
]
},
ext: {
files: [
{
expand: true,
cwd: sassDir,
src: userConfig.extension.sass,
dest: '.compass/stylesheets'
},
{
expand: true,
cwd: imagesDir,
src: userConfig.extension.images,
dest: '.compass/templates/project'
},
{
expand: true,
cwd: jsDir,
src: userConfig.extension.js,
dest: '.compass/templates/project'
},
{
expand: true,
cwd: fontsDir,
src: userConfig.extension.fonts,
dest: '.compass/templates/project'
}
]
}
},
// Concat
concat: {
rb: {
options: {
process: true
},
files: {
'.compass/lib/counter-conduct-magazine-style-guide.rb': ['.compass/.template/style-guide.rb']
}
},
gemspec: {
options: {
process: true
},
files: {
'.compass/counter-conduct-magazine-style-guide.gemspec': ['.compass/.template/style-guide.gemspec']
}
}
},
// Parallel Task
parallel: {
assets: {
options: {
grunt: true
},
tasks: ['imagemin', 'svgmin', 'uglify:dist', 'copy:dist', 'generator:dist']
},
ext: {
options: {
grunt: true
},
tasks: ['copy:ext', 'concat:rb', 'concat:gemspec']
},
remote: {
options: {
grunt: true,
stream: true
},
tasks: ['parallel:watch', 'exec:weinre']
},
remoteLaunch: {
options: {
grunt: true,
stream: true
},
tasks: ['parallel:watch', 'exec:weinre', 'exec:launch:' + remoteHost, 'exec:launch:' + remoteHost + ':' + wnport + ':client']
},
watch: {
options: {
grunt: true,
stream: true
},
tasks: ['watch', 'compass:dev']
}
},
// Exec Task
exec: {
launch: {
cmd: function(host, prt, suffix) {
prt = prt || port;
suffix = suffix || '';
return 'open http://' + host + ':' + prt + '/' + suffix;
}
},
commit: {
cmd: function(commit) {
return 'git add ' + distPath + ' && git commit -m "' + commit + '" ' + distPath;
}
},
tagMake: {
cmd: 'git tag ' + userConfig.client.version
},
tagPush: {
cmd: 'git push --tags ' + userConfig.git.deployUpstream
},
deploy: {
cmd: 'git subtree push --prefix .dist ' + gh_upstream + ' ' + gh_deploy
},
export: {
cmd: function(path) {
return 'cp -r ' + distPath + ' ' + path;
}
},
ext: {
cmd: 'cd .compass && bundle exec gem build counter-conduct-magazine-style-guide.gemspec && mv counter-conduct-magazine-style-guide-' + userConfig.client.version + '.gem ../counter-conduct-magazine-style-guide-' + userConfig.client.version + '.gem && cd ..'
},
install: {
cmd: 'gem install counter-conduct-magazine-style-guide-' + userConfig.client.version + '.gem && rm counter-conduct-magazine-style-guide-' + userConfig.client.version + '.gem'
},
weinre: {
cmd: 'weinre --httpPort ' + wnport + ' --boundHost -all-'
},
bundle: {
cmd: function(path) {
if (path === '.') {
return 'bundle install';
}
else {
return 'cd ' + path + '/ && bundle install && cd ..';
}
}
},
},
bump: {
options: {
files: [
'package.json',
'bower.json',
'.system.json'
],
commit: userConfig.bump.commit,
commitFiles: userConfig.bump.files,
createTag: userConfig.bump.tag,
push: userConfig.bump.push,
pushTo: userConfig.git.deployUpstream
}
}
});
grunt.event.on('watch', function(action, filepath) {
grunt.config([
'copy:dev',
'uglify:dev',
'generator:dev',
'jshint',
'csslint'
], filepath);
});
//////////////////////////////
// Grunt Task Loads
//////////////////////////////
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
//////////////////////////////
// Build Task
//////////////////////////////
grunt.registerTask('build', 'Production build', function() {
var commit = grunt.option('commit');
var deploy = grunt.option('deploy');
grunt.task.run(['parallel:assets', 'compass:dist', 'jshint']);
if (commit) {
if (commit === true) {
commit = gh_commit;
}
grunt.task.run(['exec:commit:' + commit]);
}
if (deploy) {
grunt.task.run(['exec:deploy']);
}
});
//////////////////////////////
// Tag Task
//////////////////////////////
grunt.registerTask('tag', 'Tags your release', function() {
var push = grunt.option('push');
grunt.task.run('exec:tagMake');
if (push) {
grunt.task.run('exec:tagPush');
}
});
//////////////////////////////
// Deploy Task
//////////////////////////////
grunt.registerTask('deploy', [
'exec:deploy'
]);
//////////////////////////////
// Export Task
//////////////////////////////
grunt.registerTask('export', 'Exports your build', function() {
var path = grunt.option('to') || exportPath;
if (grunt.file.exists(path)) {
grunt.file.delete(path, {force: true});
console.log('Folder `' + path + '` removed to ensure a clean build.');
}
grunt.task.run('build', 'exec:export:' + path);
});
//////////////////////////////
// Server Task
//////////////////////////////
grunt.registerTask('server-init', [
'copy:dev',
'uglify:dev',
'generator:dev',
'jshint',
'csslint'
]);
grunt.registerTask('server', 'Starts a development server', function() {
var launch = grunt.option('launch');
grunt.task.run(['bundler']);
grunt.task.run(['create-components']);
grunt.task.run(['server-init', 'connect']);
if (hostname == '*') {
grunt.task.run(['hostname']);
if (launch) {
grunt.task.run(['parallel:remoteLaunch']);
}
else {
grunt.task.run(['parallel:remote']);
}
}
else {
if (launch) {
grunt.task.run('exec:launch:localhost');
}
grunt.task.run('parallel:watch');
}
});
//////////////////////////////
// Hostname
//////////////////////////////
grunt.registerTask('hostname', 'Find Hostname', function() {
console.log('Server available on local network at http://' + remoteHost + ':' + port);
console.log('Remote inspector available on local network at http://' + remoteHost + ':' + wnport + '/client');
});
//////////////////////////////
// Update Bundler
//////////////////////////////
grunt.registerTask('bundler', 'Manages Development Dependencies', function(path) {
path = path || '.';
var gemfileContent = '# Pull gems from RubyGems\nsource "https://rubygems.org"\n';
_.forEach(grunt.userConfig.compass.dependencies, function(v, e) {
gemfileContent += 'gem "' + e + '", "' + v + '"\n';
});
grunt.file.write(path + '/Gemfile', gemfileContent);
grunt.task.run(['exec:bundle:' + path]);
});
//////////////////////////////
// Compass Extension
//////////////////////////////
grunt.registerTask('extension', 'Build your Compass Extension', function() {
grunt.task.run(['bundler:.compass']);
grunt.file.copy('bower.json', '.compass/templates/project/bower.json');
grunt.file.copy('.editorconfig', '.compass/templates/project/editorconfig.txt');
grunt.file.copy('.bowerrc', '.compass/templates/project/bowerrc.txt');
grunt.file.copy('.jshintrc', '.compass/templates/project/jshintrc.txt');
grunt.file.copy('.csslintrc', '.compass/templates/project/csslintrc.txt');
// Add Styleguide to Gemfile
var gemfile = grunt.file.read('Gemfile');
gemfile += '\ngem "bar-style-guide", "~>' + grunt.userConfig.client.version + '"';
grunt.file.write('.compass/templates/project/Gemfile.txt', gemfile);
grunt.task.run(['parallel:ext', 'exec:ext']);
var install = grunt.option('install');
if (install) {
grunt.task.run(['exec:install']);
}
});
//////////////////////////////
// Create Components from Templates
//////////////////////////////
grunt.registerTask('create-components', 'Build real components from component templates', function() {
// Loop over each item in components
_.forEach(grunt.userConfig.components, function(v, e) {
// Grab the template prefix for this component
var tmpl = _s.slugify(e);
// Check to see if the template exists, and if not, create it
var tmplPath = 'templates/components/' + tmpl + '.html';
if (!grunt.file.exists(tmplPath)) {
var tmplContent = '<!-- Component: {{capitalize component}}, Type: {{capitalize type}} -->';
grunt.file.write(tmplPath, tmplContent);
}
// Load the template from the templates directory
var template = grunt.file.read(tmplPath);
// Create Holder Partial
var partial = '<div class="component-group--' + tmpl + '">' +
'\n\n {{#if page.examples}}' +
'\n {{{create-example-sass "' + tmpl + '" all true}}}' +
'\n {{/if}}' +
'\n <ul component-list>' +
'\n {{#each options.grunt.userConfig.components.' + tmpl + '}}' +
'\n <li>' +
'\n {{{component "' + tmpl + '" this}}}' +
'\n\n {{#if ../page.examples}}' +
'\n {{{create-example-html "' + tmpl + '" ../this}}}' +
'\n {{{create-example-sass "' + tmpl + '" ../this}}}' +
'\n {{/if}}' +
'\n </li>' +
'\n {{/each}}' +
'\n </ul>' +
'\n</div>';
grunt.file.write('partials/components/component-group--' + tmpl + '.html', partial);
var basePath = 'sass/components/_' + tmpl + '.scss';
var mixinPath = 'sass/components/' + tmpl + '/_mixins.scss';
var extendsPath = 'sass/components/' + tmpl + '/_extends.scss';
var supportHeader = '//////////////////////////////' +
'\n// ' + _s.capitalize(e) + ' Component {{type}}' +
'\n//////////////////////////////';
var basePartial = '//////////////////////////////' +
'\n// ' + _s.capitalize(e) + ' Component' +
'\n//' +
'\n// The partial and folder structure for this component should be as follows:' +
'\n// _' + tmpl + '.scss' +
'\n// ' + tmpl + ' (folder)' +
'\n// _mixins.scss' +
'\n// _extends.scss' +
'\n//' +
'\n// Automatic Sass parsing is done through special comment blocks' +
'\n// - Start styling block for base component: @{component}' +
'\n// - End styling block for base component: {component}@' +
'\n//' +
'\n// - Start styling block for specific component configuration: @{component--configuration}' +
'\n// - End styling block for specific component configuration: {component--configuration}@' +
'\n//////////////////////////////\n' +
'\n@import "' + tmpl + '/mixins";' +
'\n@import "' + tmpl + '/extends";' +
'\n\n//////////////////////////////' +
'\n// Having $output-selectors and $output-selectors--' + tmpl + ' set to `true` will output the CSS selectors for ' + _s.capitalize(e) + 'Component' +
'\n$output-selectors--' + tmpl + ': true !default;' +
'\n@if $output-selectors and $output-selectors--' + tmpl + ' {' +
'\n//////////////////////////////' +
'\n\n//////////////////////////////' +
'\n// @{' + tmpl + '}' +
'\n// Styling for ' + _s.capitalize(e) + ' Component' +
'\n\n// {' + tmpl + '}@' +
'\n//////////////////////////////\n\n';
if (!grunt.file.exists(mixinPath)) {
grunt.file.write(mixinPath, supportHeader.replace('{{type}}', 'Mixins'));
}
if (!grunt.file.exists(extendsPath)) {
var extend = supportHeader.replace('{{type}}', 'Extendable Classes');
extend += '\n\n' +
'$' + tmpl + '-extendables-extended: false !default;' +
'\n\n@if not ($' + tmpl + '-extendables-extended) {' +
'\n // Replace this line with extendable calsses' +
'\n}' +
'\n\n$' + tmpl + '-extendables-extended: true;';
grunt.file.write(extendsPath, extend);
}
// Loop over each version of the component
_.forEach(v, function(value, name) {
var singleton = true;
// If there are no properties to this component, set the name to the value
if (typeof(name) === 'number') {
name = value;
}
// If the name is an object, pluck off its key
if (typeof(name) === 'object') {
singleton = false;
name = Object.keys(name)[0];
value = value[name];
}
// Set up Name and Component Context
var context = {'type': name, 'component': e};
// Create comment for base partial if it the partial doesn't exist
basePartial += '\n//////////////////////////////' +
'\n// @{' + tmpl + '--' + _s.slugify(name) + '}' +
'\n// ' + _s.capitalize(name) + ' styling for ' + _s.capitalize(e) + ' Component' +
'\n\n// {' + tmpl + '--' + _s.slugify(name) + '}@' +
'\n//////////////////////////////\n\n';
if (!singleton) {
// Loop over each property of the component
_.forEach(value, function(p, k) {
// Set up key context in Handlebars
context[k] = p;
});
}
// Compile the template through Handlebars
var hbCompile = Handlebars.compile(template);
// Write component to disk
grunt.file.write('partials/components/' + tmpl + '/' + tmpl + '--' + _s.slugify(name) + '.html', hbCompile(context));
});
// If the base partial doesn't exist, create it.
basePartial += '}';
if (!grunt.file.exists(basePath)) {
grunt.file.write(basePath, basePartial);
}
});
});
};