Skip to content

Instantly share code, notes, and snippets.

@simshanith
Last active December 16, 2015 15:29
Show Gist options
  • Save simshanith/5456607 to your computer and use it in GitHub Desktop.
Save simshanith/5456607 to your computer and use it in GitHub Desktop.
Building dev & production HTML with Jade & Grunt.
<!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!-->
<html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>Example Jade Template</title>
<script src="/_assets/js/modernizr-2.6.2.min.js"></script>
</head>
<body>
<h1>Example Jade Template</h1>
<p>All my dev stuffz.</p>
</body>
</html>
<!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!-->
<html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>Example Jade Template</title>
<script src="/_assets/js/modernizr-2.6.2.min.js"></script>
</head>
<body>
<h1>Example Jade Template</h1>
<p>All my prod stuffz.</p>
</body>
</html>
!!! 5
//if lt IE 7
<html class="no-js lt-ie9 lt-ie8 lt-ie7">
//if IE 7
<html class="no-js lt-ie9 lt-ie8">
//if IE 8
<html class="no-js lt-ie9">
//[if gt IE 8]><!
html.no-js(lang="en")
| <!--<![endif]-->
head
meta(charset='utf-8')
meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1')
title Example Jade Template
body
h1 Example Jade Template
- if (build==="dev")
p All my dev stuffz.
- else
p All my prod stuffz.
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
name: 'Example Grunt+Jade Build Configuration',
banner: '/* <%= meta.name %> - v<%= pkg.version %> - <%= template.today("m/d/yyyy") %> */'
},
jade: {
options: {
pretty: true,
data: {
build: '<%= grunt.task.current.target || "default" %>'
}
},
prod: {
files: [{
expand: true, // Enable dynamic expansion.
cwd: 'htdocs/', // Src matches are relative to this path.
src: ['**/*.jade'], // Actual pattern(s) to match.
dest: 'htdocs/', // Destination path prefix.
ext: '.html', // Dest filepaths will have this extension.
}]
},
dev: {
files: [{
expand: true, // Enable dynamic expansion.
cwd: 'htdocs/', // Src matches are relative to this path.
src: ['**/*.jade'], // Actual pattern(s) to match.
dest: 'htdocs/', // Destination path prefix.
ext: '.dev.html', // Dest filepaths will have this extension.
}]
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment