Skip to content

Instantly share code, notes, and snippets.

@samdbeckham
Created May 30, 2014 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samdbeckham/deb5e95040a91f44891b to your computer and use it in GitHub Desktop.
Save samdbeckham/deb5e95040a91f44891b to your computer and use it in GitHub Desktop.
<h1>Hello World!</h1>
.tmp/
dev/
- index.html
includes/
- content.html
Gruntfile.js
package.json
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-processhtml');
grunt.initConfig({
connect: {
dev: {
options: {
port: 9000,
base: '.tmp',
keepalive: true
}
}
},
processhtml: {
dev: {
options: {
includeBase: 'includes'
},
files: [{
expand: true,
cwd: 'dev',
src: ['{,*/}*.html'],
dest: '.tmp'
}]
}
}
});
grunt.registerTask('default', function() {
grunt.task.run([
'processhtml:dev',
'connect:dev',
])
})
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Grunt Includes Test</title>
</head>
<body>
<!-- build:include content.html -->
This content will be replaced by the include
<!-- /build -->
</body>
</html>
{
"name": "grunt-includes-example",
"version": "0.1.0",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.7.1",
"grunt-processhtml": "^0.3.3",
"load-grunt-tasks": "^0.4.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment