Git Product home page Git Product logo

generators's Introduction

Generators

Generators for CompoundJS MVC framework.

model

command

compound generate model modelName [ field, ... ]

modelName: word in singular form

field: word OR word:datatype, when :datatype is missing String property created

files

Model generator create/patch following files and directories:

create  ./app
create  ./app/models
create  ./app/models/modelName.js
patch   ./db/schema.js

examples

compound g model user email password approved:boolean

Example above will generate User model with the following fields:

  • email: String
  • password: String
  • approved: Boolean

Following example will generate Post(title, content) model using coffee-script

compound g post title content --coffee

controller

Generate controller with number of actions and views

command

compound generate controller controllerName [actionName, ...]

controllerName: word (plural or singular form)

actionName: word in camelcase with first lowercase letter

files

Model generator create/patch following files and directories:

exists  ./app
exists  ./app/controllers
create  ./app/controllers/controllerName_controller.js
exists  ./app/helpers
create  ./app/helpers/controllerName_helper.js
exists  ./app/views
create  ./app/views/controllerName
create  ./app/views/controllerName/actionName1.ejs
create  ./app/views/controllerName/actionName2.ejs
...
create  ./app/views/controllerName/actionNameN.ejs

examples

compound generate controller profile show edit

exists  app/
exists  app/controllers/
exists  app/helpers/
exists  app/views/
create  app/views/profile
create  app/controllers/profile_controller.js
create  app/helpers/profile_helper.js
create  app/views/profile/show.ejs
create  app/views/profile/edit.ejs

scaffold (crud)

Generate controller with CRUD actions, views, and model. Patch routes and schema. Most powerful generator for quick prototyping.

command

compound generate crud modelName [ field, ... ] [ options ]

modelName: word in singular form

field: word OR word:datatype, when :datatype is missing String property created

options:

  • --noeval - create noeval controllers
  • --tpl - specify templating engine (ejs and jade supported)

example

compound generate crud post title content

Will generate scaffold for Post(title, content) model. Following files/directories will be created:

create  client-side.js
create  app/
create  app/controllers/
create  app/helpers/
create  app/views/
create  app/views/posts/
create  app/views/layouts
exists  test/
exists  test/controllers/
create  app/controllers/posts_controller.js
exists  app/
create  app/models/
create  app/models/post.js
patch   db/schema.js
create  app/views/layouts/posts_layout.ejs
create  app/views/posts/_form.ejs
create  app/views/posts/show.ejs
create  app/views/posts/new.ejs
create  app/views/posts/edit.ejs
create  app/views/posts/index.ejs
create  app/helpers/posts.js
exists  test/controllers/posts_controller_test.js
exists  test/test_helper.js
patch   config/routes.js

License (MIT)

Copyright (C) 2011 by Anatoliy Chakkaev <mail [åt] anatoliy [døt] in>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.