Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using questions results to change options #16

Open
ElielBarone opened this issue Dec 30, 2015 · 3 comments
Open

Using questions results to change options #16

ElielBarone opened this issue Dec 30, 2015 · 3 comments

Comments

@ElielBarone
Copy link

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

@crudo
Copy link
Owner

crudo commented Jan 21, 2016

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?

@ElielBarone
Copy link
Author

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 [email protected] 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.

@ElielBarone
Copy link
Author

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
    ...

ElielBarone added a commit to ElielBarone/grunt-scaffold that referenced this issue Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants