grunt-swig-templates
Grunt plugin to compile Swig templates to static HTML
Getting Started
This plugin requires Grunt.
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-swig-templates --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "swig" task
Overview
In your project's Gruntfile, add a section named swig
to the data object passed into grunt.initConfig()
.
grunt
Options
options.data
Type: Object
Default value: {}
A Object that will get passed into swig templates
options.cache
Type: Boolean
Default value: false
A boolean that determines if templates should be cached. See more info here
options.templatePath
Type: String
Default value: undefined
A filepath string that allows loading of templates from a specific directory (does not require using relative paths in your templates)
Usage Examples
Default Options
In this example, the default options are used to show a very basic grunt configuration that will take and array of .swig
files and compile them to HTML
grunt
Custom Options
In this example, custom options are used to pass custom data to sepecified templates. This also uses the Grunt file expand mapping rather than just using the files object.
grunt
Contributing
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.
Release History
v0.1.4 - Added cache
options
v0.1.3 - Added templatePath
options #1
v0.1.2 - Updated swig library
v0.1.1 - Fixed issues with swig templating
v0.1.0 - Initial Release
License
Copyright (c) 2014 Jake Larson. Licensed under the MIT license.