-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group under one single constant name. #38
Comments
Have you tried something like this? { "CONFIG": { "person": "samir", "age": 99 } } |
I shouldn't need to change my json file to get the wanted results, but yes it works. Often times settings files don't contain a root key name like: {
"CONFIG": {
"stuff": "stuff..."
}
} It just adds an unnecessary nesting level and forces the user to adapt his json files to third party modules which I think should be avoided, especially when there is an easy solution. |
It's true that you might not want to have that complexity in the configuration file. |
Well I did create a pull request for a working solution, #35. The functionality is already in your code, we just wrap it under a new user entered field, so it would look something like:
Could name constantName to whatever sounds right, groupUnder, name, key etc. |
+1 |
I found another solution using var jeditor = require("gulp-json-editor");
var ngConstant = require('gulp-ng-constant');
gulp.src('app/config.json')
.pipe(jeditor(function (json) {
return {"Constants": json};
}, {beautify: false}))
.pipe(ngConstant({
name: "my.module.constants",
wrap: "commonjs"
}))
.pipe(gulp.dest('dist')); There is one restriction, you can't use |
Hi,
I didn't find the possibility to group under one single constant name.
Example
Given an object like:
{
"person": "samir",
"age": 99
}
I wanted to get this:
angular.module("conf", [])
.constant("CONFIG", {
"person": "samir",
"age": 99
});
but instead got this:
angular.module("conf", [])
.constant("person", "samir")
.constant"age", 99);
Using an optional parameter we can simply group the whole object under a user defined constant.
Let me know if you think this feature makes sense and I'll write the tests and update README to include an example (I just added the option explanation for now).
The text was updated successfully, but these errors were encountered: