This package has been deprecated

Author message:

Package is no longer maintained.

grunt-swig-templates

0.1.4 • Public • Published

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.loadNpmTasks('grunt-swig-templates');

The "swig" task

Overview

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

grunt.initConfig({
  swig: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})

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.initConfig({
  swig: {
    options: {},
    files: {
      'dest/test.html': ['test.swig'],
    },
  },
})

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.initConfig({
  swig: {
    options: {
      data: {
        title: 'Hello World'
      }
    },
    expand: true,
    cwd: 'templates',
    dest: 'dest/',
    src: ['*.swig'],
    ext: '.html'
  },
})

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.

Readme

Keywords

Package Sidebar

Install

npm i grunt-swig-templates

Weekly Downloads

7

Version

0.1.4

License

MIT

Last publish

Collaborators

  • larsonjj