Compile swig/django templates to html files.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-web-swig --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-web-swig');
In your project's Gruntfile, add a section named web_swig
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
web_swig: {
options: {
swigOptions:{
cache: false
},
getData: function(tpl){
return {title: 'grunt-web-swig'};
}
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
Type: Object
Default value: {cache: false}
see http://paularmstrong.github.io/swig/docs/api/#SwigOpts.
Type: Object
Default value: undefined
see https://github.com/yanni4night/django#configurations.
Type: Function
or Object
Default value: function(tpl){return {};}
Mock data for each source template file.
Type: Boolean
Default value: false
Use Django's template syntax.Note you have to follow some instructions about python env,see https://www.npmjs.org/package/django#install.
1.7
is supported now.
Type: String
Default value: undefined
If you're using absolute path in @include or @extend,you have to define template_dirs or loader for django or swig,beside that you have to define an ignorePrefix to remove the prefix path returned by grunt.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.