Socket
Socket
Sign inDemoInstall

grunt-fest-next

Package Overview
Dependencies
31
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grunt-fest-next

Compile Fest templates


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
441 kB
Created
Weekly downloads
 

Readme

Source

grunt-fest Build Status

Compile Fest templates.

Getting Started

This plugin requires Grunt ~0.4.0

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-fest --save-dev

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

grunt.loadNpmTasks('grunt-fest-next');

The "fest" task

Overview

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

grunt.initConfig({
    fest: {
        options: {
            // Task-specific options go here.
        },
        target: {
            options: {
                // Target-specific options go here.
            }
        }
    }
})

Options

options.require

Type: String Default value: fest

Path to require Fest library.

options.compile

Type: Object Default value: undefined

Fest’s compile() options.

options.ext

Type: String Default value: .js

Compiled file’s extension.

options.name

Type: String Default value: undefined

Compiled function’s name. The basename of the source file will be used if is set to True.

options.template

Type: Function Default value: undefined

This function is called when template will be compiled. It takes an argument as an object with the following properties:

  • src — path to the template
  • relSrc — relative path to the template
  • dest — path to the compiled file
  • name — template’s name (relative to the source directory and w/o the extension)
  • basename — template’s basename
  • contents — compiled template

Usage Examples

Static mappings
grunt.initConfig({
    fest: {
        options: {
            compile: {
                beautify: true,
                debug: true
            }
        },

        // Compiles "fest/**/*.xml" to "fest/**/*.js"
        put_in_the_same_derictory: {
            src: 'fest/**/*.xml'
        },

        // Compiles "fest/**/*.xml" to "fest/**/*.xml.js"
        put_in_the_same_derictory_and_append_ext: {
            src: 'fest/**/*.xml',
            options: {
                ext: '.xml.js'
            }
        },

        // Compiles "test/**/*.xml" to "build/fest/**/*.js",
        'build': ['fest/**/*.xml'],

        // Compiles "test/qux.xml" to named function and writes it to "build/qux.js"
        v8: {
            src: 'fest/qux.xml',
            dest 'build/qux.js',
            options: {
                name: 'qux'
            }
        }
    }
})
Dynamic mappings

In this example Fest compiles "fest//*.xml" to "fest-build//*.js". See Building the files object dynamically documentation for more information.

grunt.initConfig({
    fest: {
        build: {
            files: [{
                expand: true,       // Enable dynamic expantion.
                cwd: 'fest',        // Src matches are relative to this path.
                src: ['**/*.xml'],  // Actual pattern(s) to match.
                dest: 'fest-build', // Destination path prefix.
                ext: '.js'          // Dest filepaths will have this extension.
            }],
            options: {
                compile: {
                    debug: false,
                    beautify: false
                }
            }
        }
    }
})
Template’s Usage

In this example Grunt builds AMD modules for the compiled templates.

grunt.initConfig({
    fest: {
        build: {
            files: [{
                expand: true,       // Enable dynamic expantion.
                cwd: 'fest',        // Src matches are relative to this path.
                src: ['**/*.xml'],  // Actual pattern(s) to match.
                dest: 'fest-build', // Destination path prefix.
                ext: '.js'          // Dest filepaths will have this extension.
            }],
            options: {
                template: function (data) {
                    // Make AMD module
                    return grunt.template.process(
                        'define(<%= JSON.stringify(name)  %>, function () { return <%= contents %> ; });',
                        {data: data}
                    );
                },
                compile: {
                    debug: false,
                    beautify: false
                }
            }
        }
    }
});

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. Before pull-request to dev branch do rebase.

Release History

  • 2013-11-27 v0.1.4 Upgraded dependencies
  • 2013-05-24 v0.1.3 Support for function name within dynamic mappings
  • 2013-03-13 v0.1.2 Added option to name compiled function
  • 2013-03-04 v0.1.1 Use of initial compile options
  • 2013-02-22 v0.1.0 First official release

Keywords

FAQs

Last updated on 02 Apr 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc