Compile Caveman templates on the server-side using Grunt. Optionally render templates on the server-side as well.
npm install grunt-caveman
Add the grunt-caveman task to your Grunt config:
grunt.loadNpmTasks('grunt-caveman');
caveman: {
compile: {
src: ['path/to/templates/*.html'],
dest: 'public/templates.js'
}
}
var myTemplateData = { foo: [1, 2, 3], bar: true };
var html = Caveman.render('myTemplateName', myTemplateData);
document.getElementById('foo').innerHTML = html;
caveman: {
compile: {
src: ['path/to/templates/*.html'],
data: {
foo: [1, 2, 3],
bar: true
},
render: {
'indexPage': 'public/index.html',
'aboutPage': 'public/about/index.html',
'contactPage': 'public/contact/index.html'
}
}
}
MIT. Copyright © 2016 Andrew Childs