0.4.0 • Published 9 years ago

grunt-partial-extract v0.4.0

Weekly downloads
1
License
-
Repository
github
Last release
9 years ago

grunt-partial-extract

Extract partials from any text based file and write to distinct file.

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-partial-extract --save-dev

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

grunt.loadNpmTasks('grunt-partial-extract');

The "partial-extract" task

Overview

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

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

Options

grunt.initConfig({
  'partial-extract': {
    options: {
        // Find partials by pattern:
        //
        // <!-- extract:individual-file.html optional1:value optional2:value1:value2 -->
        //   partial
        // <!-- endextract -->
        patternExtract: new RegExp(/<!--\s*extract:(.|\n)*?endextract\s?-->/g),
        // Wrap partial in template element and add options as data attributes
        templateWrap: {
            before: '<template id="partial" {{wrapData}}>',
            after:  '</template>'
        },
        // Wrap component for viewing purposes: e.g. add production context
        //
        // <!-- extract:individual-file.html wrap:<div class="context">:</div> -->
        //   partial
        // <!-- endextract -->
        //
        // results in
        //
        // <div class="context">
        //   partial
        // </div>
        viewWrap: {
            before: '',
            after: ''
        },
        // Base directory
        base: './inventory',
        // Partial directory where individual partial files will be stored (relative to base)
        partials: './partials',
        // Store inventory data as JSON file
        storage: 'partial-extract.json',
        // Enable storing partials as individual files
        storePartials: false,
        // Set indent value of partial code
        indent: '    '
    },
    files: [],
  },
});

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

(Nothing yet)

0.4.0

9 years ago

0.3.0

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago