Question

I'm writing a version of generator-angular with extra options to support sources in livescript, and bootstrap with less, font-awesome etc. Work in progress is at https://github.com/gmp26/generator-angular-ls

I'm hung up on a trivial wish. I'd like the initial 'Halo 'Halo installed list to reflect the options installed in response to yeoman questions rather than be a constant common denominator list.

As a first attempt - I tried lodash templates in templates/*/spec/controller.(ls|js|coffee) to adjust the $scope.awesomeThings list which is defined in those files. This fails because my optional flags defined by prompt (this.bootstrap, this.lessBootstrap, this.fontAwesome) in a similar manner to generator-angular's this.bootstrap and this.compassBootstrap are not available in the 'this' context where the template is called. Both 'this' contexts are Generators but I believe the prompting 'this' context is the generator angular:app whereas the template is called in angular:controller.

So, any ideas how to communicate a flag from the app/index.js prompting phase through to the templating phase?

I feel there should be a way to do this that does not involve writing and reading files in the generated app folder.

Maybe this is what the hookFor calls are for?

Was it helpful?

Solution 2

My question is essentially the same as yeoman-generator issue #312, which is resolved there by the addition of a parameter storage API using the file .yo-rc.json.

A file based store is necessary because yeoman subgenerators can be called independently from 'yo' as well as via the main generator. The hookFor solution can only work from the main generator.

OTHER TIPS

Yes - it appears that options can be passed to other generators through the hookFor calls that already exist in generator-angular. See solution in this commit

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top