generator-ng-poly icon indicating copy to clipboard operation
generator-ng-poly copied to clipboard

Support for custom templates

Open dustinspecker opened this issue 9 years ago • 0 comments

Users should be able to create custom templates for each component.

In a /templates/ directory will exist directories such as directive/ and service/. Within these directories will be files such as _directive.coffee, _directive.es6, _directive.jade, etc. If one of these files exists, ng-poly will use these templates instead of its own.

A template generator will be added to ng-poly that simply copies its own template to the user's templates/ directory for modification. The template generator will be used like yo ng-poly template directive and will copy the templates using the project settings in the .yo-rc.json file. For example, a .yo-rc.json file looking like:

{
  "generator-ng-poly": {
    "appScript": "ts",
    "controllerAs": true,
    "directiveTemplateUrl": true,
    "e2eTestFramework": "jasmine",
    "markup": "jade",
    "ngRoute": false,
    "structure": "module-type",
    "style": "less",
    "testFramework": "jasmine",
    "testScript": "ts"
  }
}

and the command yo ng-poly template directive will create /templates/directive/_directive.ts, /templates/directive/_directive.jade, and /templates/directive/_spec.ts.

Add to README.md about how to use the template generator and what is passed to the template's context via ng-poly.

Most components should be simple to add support for. Routes and modules may be tricky because ng-poly expects a specific format to be able to modify correctly. Maybe investigate adding an optional comment such as // ROUTES INSERT POINT to be used by templates, so ng-poly knows where to insert code.

dustinspecker avatar Oct 04 '15 16:10 dustinspecker