Skip to content

Commit

Permalink
Optional: HTML5 Shiv
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Miranda committed Apr 6, 2014
1 parent f9a1eeb commit 9400d20
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
24 changes: 17 additions & 7 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
});
},

hasFeature: function (list, feat) {
return (list || []).indexOf(feat) !== -1;
},

askFor: function () {
var scope = this;
var done = this.async();

// have Yeoman greet the user
Expand All @@ -27,7 +32,7 @@
var prompts = [
{
type: 'checkbox',
name: 'features',
name: 'Features',
message: 'What more would you like?',
default: true,
choices: [
Expand All @@ -37,16 +42,21 @@
checked: true
}
]
},
{
type: 'confirm',
name: 'HTML5Shiv',
value: 'includeHTML5Shiv',
message: 'Would you like to use a crossbrowser workaround to ' + chalk.red('HTML5') + '?',
when: function (answers) {
return !scope.hasFeature(answers.Features, 'includeModernizr');
}
}
];

this.hasFeature = function (list, feat) {
return list.indexOf(feat) !== -1;
};

this.prompt(prompts, function (props) {
var features = (props.features || []);
this.includeModernizr = this.hasFeature(features, 'includeModernizr');
this.includeModernizr = this.hasFeature(props.Features, 'includeModernizr');
this.includeHTML5Shiv = props.HTML5Shiv;
done();
}.bind(this));
},
Expand Down
3 changes: 2 additions & 1 deletion app/templates/_bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"private": true,
"dependencies": {
"requirejs": "~2.1.11",<% if (includeModernizr) { %>
"modernizr": "~2.6.2",<% } %>
"modernizr": "~2.6.2",<% } else { if (includeHTML5Shiv) { %>
"html5shiv": "~3.7.0",<% }} %>
"jquery": "~2.1.0"
},
"devDependencies": {},
Expand Down
13 changes: 9 additions & 4 deletions app/templates/_gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
//|
//| Gulpfile
//|
//| This file is the streaming build system generated on <%= (new Date).toISOString().split('T')[0] %>
//| using <%= pkg.name %> <%= pkg.version %>
//| This file is the streaming build system
//|
//| .--------------------------------------------------------------.
//| | NAMING CONVENTIONS: |
Expand Down Expand Up @@ -175,7 +174,7 @@
//'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
gulp.task('html', ['styles', 'scripts'], function() {
var js = $.filter('**/*.js'), css = $.filter('**/*.css');
return gulp.src(_.app + '/*.html')
return gulp.src([_.app + '/*.html'])
.pipe($.useref.assets())
.pipe(js)
.pipe($.uglify())
Expand All @@ -186,7 +185,13 @@
.pipe($.useref.restore())
.pipe($.useref())
.pipe(gulp.dest(_.dist))
.pipe($.size());
.pipe($.size())
.pipe($.notify({
message: '<%= options.date %> ✓ html: <%= file.relative %>',
templateOptions: {
date: new Date()
}
}));
});

//|**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
11 changes: 9 additions & 2 deletions app/templates/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
<!-- endbuild --><% if (includeModernizr) { %>
<!-- build:js scripts/header.js -->
<script src="scripts/vendor/modernizr/modernizr.js"></script>
<!-- endbuild --><% } %>
<!-- endbuild --><% } else { if (includeHTML5Shiv) { %>
<!--[if lt IE 9]>
<!-- build:js scripts/header.js -->
<script src="scripts/vendor/html5shiv/dist/html5shiv.js"></script>
<!-- endbuild -->
<![endif]--><% }} %>
</head>
<body>
<!--[if lt IE 10]>
Expand All @@ -31,7 +36,9 @@ <h1>'Allo, 'Allo!</h1>
<li>HTML5 Boilerplate</li>
<% if (includeModernizr) { %>
<li>Modernizr</li>
<% } %>
<% } else { if (includeHTML5Shiv) { %>
<li>HTML5 Shiv</li>
<% }} %>
</ul>
</div>

Expand Down

0 comments on commit 9400d20

Please sign in to comment.