Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Convert java .properties files to javascript
JavaScript
branch: master

0.2.1

latest commit ec5e74a628
@heldr authored
Failed to load latest commit information.
tasks add keysSplitter to generate nested object
test add keysSplitter to generate nested object
.gitignore Initial release
.jshintrc jshintrc: removed prop that is turned on by default now
.npmignore Initial release
.travis.yml get last npm version
Gruntfile.js add keysSplitter to generate nested object
LICENSE-MIT
README.md bump version #5
package.json 0.2.1

README.md

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

Something went wrong with that request. Please try again.