gulp-ng-constant
gulp-ng-constant copied to clipboard
JSON as single constant
Just FYI for future users, my use case was converting a JSON dictionary into a single app constant. My flow was using a gulp module to create a json file which then is converted into Angular constant.
Thanks for providing the EJS template ability to customize the output.
angular.module("<%- moduleName %>"<% if (deps) { %>,${JSON.stringify(deps)}<% } %>)
${indent}.constant({"myDictionary": {
<% constants.forEach(function(constant) { %>
"<%- constant.name %>": ${constant.value},
<%= _.last(constants) === constant ? '' : '\n' %>
<% }) %>}});
@ericjames I found EJS templating solution too complicated for this purpose.
Look at my solution: https://github.com/guzart/gulp-ng-constant/issues/38#issuecomment-345352560