Comments (8)
Could you please provide a complete configuration and describe a little bit more what you want to do?
from grunt-ng-constant.
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.
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.
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.
Yeah it is currently only supported in the Git version. Is this working for you?
from grunt-ng-constant.
oppsss. i need it at npm to support for node server side. when will it be available at npm?
from grunt-ng-constant.
I don't have an exact timeline. I am also thinking about some changes. Maybe next month.
from grunt-ng-constant.
great..good work... I'd like to thank you for your prompt reply.
from grunt-ng-constant.
Related Issues (20)
- Unable to write "undefined" file HOT 4
- Add space option for backwards compability HOT 1
- Set value for a constant file with differents targets HOT 1
- Release 0.5.0 HOT 4
- Constant works only with string values, no support for functions HOT 3
- Release 1.0.0 HOT 3
- Objects and Function as constatnt. HOT 1
- DOCS: The example doesn't work well for generated constant value files HOT 3
- Pull Constants from .json File? HOT 1
- Usage in index.html HOT 3
- Is it possible to write a constant to an already existing module and not create a new one? HOT 1
- Add useStrict option to configuration HOT 6
- Dynamic constants HOT 1
- possible to add multiple ngconstants to a task? HOT 3
- options.deps in false by default HOT 1
- Update lodash please
- will the config file be built in main js file or will be inserted in index.html file? HOT 5
- Issue with no-shadow-restricted-names ESLint rule HOT 1
- Git vulnerability - Required updated version of merge plugin to ^1.2.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-ng-constant.