UNPKG

grunt-contrib

Version:
106 lines (86 loc) 2.28 kB
## Compile Jade files to HTML > Contributed By: [Eric Woroshow](/errcw) (@errcw) ### Overview Inside your `grunt.js` file add a section named `jade`. This section specifies files to compile and the options passed to [jade](https://github.com/visionmedia/jade#public-api). #### Parameters ##### files ```object``` This defines what files this task will process and should contain key:value pairs. The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)). Note: When the value contains an array of multiple filepaths, the contents are concatenated in the order passed. ##### options ```object``` This controls how this task (and its helpers) operate and should contain key:value pairs, see options below. #### Options ##### data ```object``` Sets the data passed to ```jade``` during template compilation. Any data can be passed to the template (including ```grunt``` templates). #### Config Examples ``` javascript jade: { compile: { options: { data: { debug: false } }, files: { "path/to/dest.html": ["path/to/templates/*.jade", "another/path/tmpl.jade"] } } } ``` If you want to generate a debug file and a release file from the same template: ``` javascript jade: { debug: { options: { data: { debug: true } }, files: { "debug.html": "test.jade" } }, release: { options: { data: { debug: false } }, files: { "release.html": "test.jade" } } } ``` If you want to use `grunt` template in `options.data`: ``` javascript jade: { debug: { options: { data: { debug: true, timestamp: "<%= new Date().getTime() %>" } }, files: { "debug.html": "test.jade" } } } ``` or you can use `grunt` helpers (grunt object was exposed at template context): ``` javascript jade: { debug: { options: { data: { debug: true, timestamp: "<%= grunt.template.today() %>" } }, files: { "debug.html": "test.jade" } } } ```