grunt-properties

0.2.1 • Public • Published

grunt-properties Build Status

Convert java .properties files to javascript

"JavaScript isn't a great way to store configuration data. That's because the syntax is still that of a programming language, so you need to be sure you haven't introduced syntax errors. If you end up concatenating JavaScript files together, a syntax error in a single line breaks the overall application" ( Nicholas C. Zakas, Maintainable JavaScript, Writing Readable Code, O'Reilly Media, May 2012)

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

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

grunt.loadNpmTasks('grunt-properties');

The "properties" task

Overview

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

grunt.initConfig({
  properties: {
    page_config: {
      files: {
        'tmp/page_config.js': ['test/fixtures/page_config.properties'],
      },
    },
    page_color_config: {
      options: {
        namespace: 'mypage'
      },
      files: {
        'tmp/page_color_config.js': ['test/fixtures/page_config.properties', 'test/fixtures/page_color_config.properties'],
      },
    },
  },
})

Options

options.namespace

Type: String Default value: 'config'

Use a previously defined namespace.

Usage Examples

Default namespace config

grunt.initConfig({
  properties: {
    options: {},
    files: {
      'tmp/page_config.js': ['test/fixtures/page_config.properties'],
    },
  },
})

Customized namespace

grunt.initConfig({
  properties: {
    page_color_config: {
      options: {
        namespace: 'mypage'
      },
      files: {
        'tmp/page_color_config.js': ['test/fixtures/page_config.properties', 'test/fixtures/page_color_config.properties'],
      },
    },
  },
})

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

  • 2013-05-22   v0.1.0   Initial release.

Credits

Package Sidebar

Install

npm i grunt-properties

Weekly Downloads

53

Version

0.2.1

License

none

Last publish

Collaborators

  • helder