Git Product home page Git Product logo

Comments (8)

mlegenhausen avatar mlegenhausen commented on June 10, 2024

Could you please provide a complete configuration and describe a little bit more what you want to do?

from grunt-ng-constant.

martingg88 avatar martingg88 commented on June 10, 2024

The following is the implementation of 'ngconstant'.

ngconstant will skip off 'JST' in the result set as it couldn't support for 'function' data type.

I'd like to expect "JST" with the function data type returned in the result set.

module.exports = function(grunt) {

grunt.config.set('ngconstant', {
    options:{
        name: 'app.env',
        wrap: "'use strict';\n\n {%= __ngModule %}",
        dest: 'assets/js/config/env.js'
    },
    dev:{
        constants:  {
                appConfig : {   

                                jst: function(key){ return (typeof key == 'undefined') ? window['JST'] : window['JST'][key]();}

                            }
                    }
    }
});

grunt.loadNpmTasks('grunt-ng-constant');

};

from grunt-ng-constant.

mlegenhausen avatar mlegenhausen commented on June 10, 2024

The default serializer that write your appConfig constant in the file is JSON.stringify this serializer does not support functions. You can try using the tosource serializer. Change the configuration as follows:

grunt.config.set('ngconstant', {
    options:{
        name: 'app.env',
        wrap: "'use strict';\n\n {%= __ngModule %}",
        dest: 'assets/js/config/env.js',
        serializer: 'source' // default is 'json'
    },
    dev:{
        constants:  {
                appConfig : {   

                                jst: function(key){ return (typeof key == 'undefined') ? window['JST'] : window['JST'][key]();}

                            }
                    }
    }
});

from grunt-ng-constant.

martingg88 avatar martingg88 commented on June 10, 2024

I do have installed this library from npm but it looks like "toSource" is not included in npm version, but it does in GIT version. are you sure npm is updated with GIT one?

from grunt-ng-constant.

mlegenhausen avatar mlegenhausen commented on June 10, 2024

Yeah it is currently only supported in the Git version. Is this working for you?

from grunt-ng-constant.

martingg88 avatar martingg88 commented on June 10, 2024

oppsss. i need it at npm to support for node server side. when will it be available at npm?

from grunt-ng-constant.

mlegenhausen avatar mlegenhausen commented on June 10, 2024

I don't have an exact timeline. I am also thinking about some changes. Maybe next month.

from grunt-ng-constant.

martingg88 avatar martingg88 commented on June 10, 2024

great..good work... I'd like to thank you for your prompt reply.

from grunt-ng-constant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.