steal.generate  function     

plugin: steal/generate

The Generate plugin makes building code generators crazy easy. StealJS comes with its own app generator. JavaScriptMVC has more complex generators.

Steal Generators

  • app - creates an application structure, build and clean scripts.
    js steal/generate/app path/to/app [OPTIONS]
    path/to/app
    The lowercase path you want your application in.

JavaScriptMVC Generators

  • app - creates a JavaScriptMVC application structure.
    js jquery/generate/app path/to/app [OPTIONS]
    path/to/app
    The lowercase path you want your application in. Keep application names short because they are used as namespaces. The last part of the path will be taken to be your application's name.
  • controller - creates a JavaScriptMVC jQuery.Controller.
    js jquery/generate/controller App.Controllers.Name [OPTIONS]
    App.Controllers.Name
    The namespaced name of your controller. For example, if your controller is named Cookbook.Controllers.Recipe, the generator will create cookbook/controllers/recipe_controller.js.
  • model - creates a JavaScriptMVC jQuery.Model.
    js jquery/generate/model App.Models.Name [TYPE] [OPTIONS]
    App.Models.Name
    The namespaced name of your model. For example, if your model is named Cookbook.Models.Recipe, the generator will create cookbook/models/recipe.js.
  • page - creates a page that loads steal.js and an application.
    js jquery/generate/model path/to/app path/to/page.html
    path/to/app
    The path to your apps folder.
    path/to/page.html
    The path to the page you want to create.
  • plugin - creates a JavaScriptMVC plugin file and folder structure.
    js jquery/generate/plugin path/to/plugin [OPTIONS]
    path/to/plugin
    The path to where you want your plugin. This also should be the namespace and name of whatever JavaScript object created. Check out mxui for examples.
  • scaffold - creates the controllers, models, and fixtures used to provide basic CRUD functionality..
    js jquery/generate/scaffold App.Models.ModelName [OPTIONS]
    App.Models.ModelName
    The model resource you want to add CRUD functionality to.

The Generator Function

Renders a folders contents with EJS and data and then copies it to another folder.

steal.generate(
  "path/to/my_template_folder",
  "render/templates/here", 
  {
    data: "to be used"
  })
steal.generate(path, where, data) -> undefined
{String}

the folder to get templates from

{String}

where to put the results of the rendered templates

{Object}

data to render the templates with. If force is true, it will overwrite everything

{undefined}
© Jupiter IT - JavaScriptMVC Training and Support