#require-java-properties
a transform for loading Java .properties files in RequireJS, using java.properties.js
$ bower install java.properties.js --save
If you prefer a manual install, make sure to satisfy the java.properties.js
and text
dependencies.
First, make sure the module names java.properties.js
and text
resolve to the proper locations:
requirejs.config({
paths : {
'text': './bower_components/requirejs-text/text',
'java.properties': './bower_components/java.properties.js/dist/amd/java.properties',
'properties': './bower_components/require-java-properties/properties'
}
});
Now you're ready to require
Java .properties files as plain JavaScript objects:
require('properties!some/folder/afile.properties', function(data){
console.log(data); // => logs the transformed object
});
NOTE: In contrast to the default java.properties.js behaviour keys with dots in them will not result in nested objects. So a properties key like:
key=12
key.with.dots=foobar
Will result in this JavaScript object:
{
"key": 12,
"key.with.dots": "foobar"
}
This is due to the specific requirements for which this plugin was build.
On build time you can simply use stubModules
in your build config to get rid of the parser in the file you ship to production:
({
stubModules: ['text', 'java.properties', 'properties']
})
##License MIT
##Attribution This plugin is a based upon require-yaml.