Grunt preprocess and templating plugin using swig
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
tasks
test
.gitignore
.jshintrc
Gruntfile.js
LICENSE-MIT
README.md
package.json

README.md

grunt-tasty-swig

Grunt preprocess and templating plugin using swig

Getting Started

This plugin requires Grunt ~0.4.1

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-tasty-swig --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-tasty-swig');

The "tasty_swig" task

Overview

In your project's Gruntfile, add a section named tasty_swig to the data object passed into grunt.initConfig().

grunt.initConfig({
  tasty_swig: {
    options: {
      data: 'build/data',
      context: {
        'hello': 'Alloha'
      }
    },
    index: {
      context: {
          'word': 'World'
      },
      src: ['templates/**.swig'],
      dest: 'build/templates'
    }
  },
})

Options

options.context

Type: Object Default value: {}

Global template variables for swig

options.data

Type: String Default value: ''

A string value that is used to do find .json files with template variables.

options.extension

Type: String Default value: .swig

A filename extension for templates

options.extendSwig

Type: function Default value: null Parameters: swig

A callback function for extend swig template engine.

For example:

function(swig) {
  function replaceMs(input) { return input.replace(/m/g, 'f'); }
  swig.setFilter('replaceMs', replaceMs);
}
// => {{ "onomatopoeia"|replaceMs }}
// => onofatopeia

More on http://paularmstrong.github.io/swig/docs/api/

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

0.1.0 - Initial