Open ElielBarone opened 8 years ago
Hi @ElielBarone, I do not see this as a good idea. Couldn't you just call grunt.config.get('scaffold'); to get the options inside the filter function?
Hi Martin, thank you. Sorry for my ignorance, I will try in that way, if I have success I'll let you know
Thank you again
Enviado do meu iPad
Em 21/01/2016, às 10:26, Martin Cermak notifications@github.com escreveu:
Hi @ElielBarone, I do not see this as a good idea. Couldn't you just call grunt.config.get('scaffold'); to get the options inside the filter function?
— Reply to this email directly or view it on GitHub.
Hi @crudo, I did the way you advised me, but I had no success, take a look bellow:
function filter(result){
var template = grunt.config.get('scaffold.form.options.template');
//get the reference to the template
if(result.generate_form){
//I run my logic to define the template
template["skeletons/skeleton-form.service.js"] = "src/components/[[name]]/[[name]]-form.service.js";
}
grunt.config.set('scaffold.form.options.template', template);
//adds the template again (I think it replaces the old reference)
//I did try merge also
}
but it does not work, I saw your code inside the task:
var _process = function(result) { var template = options.template || {}; // you took the reference here
if (options.filter && _.isFunction(options.filter)) {
result = options.filter(result);
// My code run here
}
Object.keys(template).forEach(function(key){
// but here the reference to the template is not the same that I have changed
...
Please, add options as parameter on options.filter like bellow:
result = options.filter(result, options);
So we can use results to change options like templates
thanks