gulp-ng-constant icon indicating copy to clipboard operation
gulp-ng-constant copied to clipboard

JSON as single constant

Open ericjames opened this issue 7 years ago • 1 comments

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 avatar Jul 06 '17 17:07 ericjames

@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

ViieeS avatar Nov 17 '17 20:11 ViieeS