1

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?

4

2 回答 2

0

我的问题本质上与 yeoman-generator问题 #312相同,该问题通过使用文件 .yo-rc.json添加参数存储 API来解决。

基于文件的存储是必要的,因为 yeoman 子生成器可以独立于 'yo' 以及通过主生成器调用。hookFor 解决方案只能在主生成器上工作。

于 2013-08-28T10:14:54.117 回答
0

是的 - 似乎可以通过生成器角度中已经存在的 hookFor 调用将选项传递给其他生成器。请参阅此提交中的解决方案

于 2013-08-27T09:54:19.020 回答