grunt-web-swig

0.3.1 • Public • Published

grunt-web-swig

Compile swig/django templates to html files.

NPM version Downloads Build Status Build status Dependency status De vDependency status Built with Grunt

Getting Started

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');

The "web_swig" task

Overview

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.
    },
  },
});

Options

options.swigOptions

Type: Object Default value: {cache: false}

see http://paularmstrong.github.io/swig/docs/api/#SwigOpts.

options.djangoOptions

Type: Object Default value: undefined

see https://github.com/yanni4night/django#configurations.

options.getData

Type: Function or Object Default value: function(tpl){return {};}

Mock data for each source template file.

options.useDjango

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.

options.ignorePrefix

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.

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

  • 2016-04-01[13:31:23]:update dependencies;support grunt 1.x
  • 2014-11-06[11:29:58]:support swig
  • 2014-11-28[18:44:12]:support django
  • 2014-12-03[19:16:33]:fixed hangup;add a djangoOptions to support absolute tempalte resolving path.

Readme

Keywords

Package Sidebar

Install

npm i grunt-web-swig

Weekly Downloads

5

Version

0.3.1

License

none

Last publish

Collaborators

  • yinyongcom666