Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 6384a7d6a6
Fetching contributors…

Cannot retrieve contributors at this time

81 lines (58 sloc) 3.19 KB

Customizing the Sub-generators

You may need to customize the sub-generators if you use things like SASS, RequireJS, and more. The sub-generators can be extended and overriden through the .yo-rc.json file. The .yo-rc.json file can be configured with the following properties:


Type: String

Directory to load partial template files from.


Type: String

Directory to load directive template files from if the user has chosen to create a directive without an external partial.


Type: String

Directory to load directive template files from if the user has chosen to create a directive with an external partial.


Type: String

Directory to load service template files from.


Type: String

Directory to load filter template files from


Type: Object

A map of file extensions where each extension key contains another map containing 3 properties (file, template, marker). The sub-generators use these options to inject script tags and import statements. These options can be extended to add new file types, or override to change the existing injection behavior.

Example Configuration

Here is an example configuration that matches the default behavior of the sub-generators:

    uirouter: false,
    partialDirectory: "partial/",
    directiveDirectory: "directive/",
    serviceDirectory: "service/",
    filterDirectory: "filter/",
    partialTemplates: "templates/partial",
    directiveSimpleTemplates: "templates/simpleDirective",
    directiveComplexTemplates: "templates/complexDirective",
    serviceTemplates: "templates/service",
    filterTemplates: "templates/filter",
    "inject": {
      "js": {
        "file": "index.html",
        "marker": "<!-- Add New Component JS Above -->",
        "template": "<script src=\"<%= filename %>\"></script>"
      "less": {
        "file": "app.less",
        "marker": "/* Add Component LESS Above */",
        "template": "@import \"<%= filename %>\";"

If a given template property is missing, the default templates will be used.

Template Directories

Each template directory can contain any number of files for a given sub-generator. Each file will be read, run through the template engine, and then saved to the user specified destination. The name of the destination file will be derived from the name of the template file after a word replacement has been done. Each type of sub-generator will replace the sub-generator type word in the name with the user specified component name. In other words, a template file named partial-spec.js, when the user creates a component named my-component, will turn into a destination file named my-component-spec.js.

Template variables

All templates are valid underscore templates using the standard ERB-style delimiters. The templates will also have the following variables:

  • appname - name of the Angular app/module name
  • name - the name of the component entered by the user
  • ctrlname - (partials only) name of the controller
  • _ - Underscore.js with Underscore.string mixed in. This allows you to use code like <%= _.camelize(name) %> in the templates.
Jump to Line
Something went wrong with that request. Please try again.