Skip to content

基于angular + yeoman + nodejs + bower + requirejs 构架前端架构,支持本地mock数据(get/post)。简单命令生成项目架构,自动生成router,view,controller等。

Notifications You must be signed in to change notification settings

sisilai/generator-webbp

 
 

Repository files navigation

generator-webbp Build Status

Yeoman generator

Getting Started

npm install -g yo

Yeoman Generators

Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.

To install generator-webbp from npm, run:

npm install -g generator-webbp

Finally, initiate the generator:

yo webbp

子命令

  • 单步生成controller
yo webbp:controllers detail.about.contact

亮点:可以嵌套,此命令会生成如下文件

|controllers
   |detail
      |about.js
      |contact.js
    detail.js

另外detail.js中会自动加载about.js及contact.js

  • 单步生成views
yo webbp:views detail.about.contact

亮点:可以嵌套,此命令会生成如下文件

|views
   |detail
      |about.html
      |contact.html
    detail.html
  • 单步生成routes
yo webbp:routess detail.about.contact

亮点:可以嵌套,此命令会生成如下文件

|states
  |detail.js

其内容是:

define(['./states', '../cons/simpleCons'],
    function (stateModule, simpleCons) {
      stateModule.config(
          ['$stateProvider', '$urlRouterProvider',
            function ($stateProvider, $urlRouterProvider) {
              $stateProvider.state("detail", {
                abstract: true,
                resolve: {
                  instanceBasicPromise: [ '$stateParams', function( $stateParams){

                  }]
                },
                url: "/detail",
                controller: 'detailController',
                templateUrl: simpleCons.VIEW_PATH + 'detail.html'
              })
              
                .state("detail.about", {
                  url: "/about",
                  views: {
                    detail: {
                      templateUrl: simpleCons.VIEW_PATH + 'detail/about.html',
                      controller: 'detail.aboutController'
                    }
                  }
                })  
              
            }
          ]);
    })

亮点:通过运行此命令,会自动生成 routes(用的是ui-router,目录是states目录),view,controller。有没有觉得很爽的感觉。

License

MIT

About

基于angular + yeoman + nodejs + bower + requirejs 构架前端架构,支持本地mock数据(get/post)。简单命令生成项目架构,自动生成router,view,controller等。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.6%
  • HTML 2.4%