mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 22:05:23 +02:00
chore(project): add angular components code snippets (#3649)
* chore(project): add angular components code snippets * chore(project): add plopjs templates * feat(project): use class in controller template * chore(client): rename generators * chore(vscode): fix controller snippets * chore(git): ignore only specific files in .vscode * chore(plop): move generators to app * chore(plop): fix portainer module * fix(git): fix gitignore vscode * chore(vscode): remove symling to code-snippets * refactor(build): move plop templates to root * feat(build): add readme for plop
This commit is contained in:
parent
38066ece33
commit
766ced7cb1
9 changed files with 804 additions and 33 deletions
16
plop-templates/README.md
Normal file
16
plop-templates/README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Plop generator
|
||||
|
||||
We use [plop.js](https://plopjs.com/) to generate angular components in our app (in the future we might use it for other things).
|
||||
in order to create a component with the name `exampleComponent`, go in your terminal to the folder in which you want to create the component (for example, if I want to create it in the portainer module components, I'll go to `./app/portainer/components`). then execute the following line:
|
||||
|
||||
```
|
||||
yarn plop exampleComponent
|
||||
```
|
||||
|
||||
this will create the following files and folders:
|
||||
|
||||
```
|
||||
example-component/index.js - the component file
|
||||
example-component/exampleComponent.html - the template file
|
||||
example-component/exampleComponentController.js - the component controller file
|
||||
```
|
6
plop-templates/component-controller.js.hbs
Normal file
6
plop-templates/component-controller.js.hbs
Normal file
|
@ -0,0 +1,6 @@
|
|||
class {{properCase name}}Controller {
|
||||
/* @ngInject */
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
export default {{properCase name}}Controller;
|
1
plop-templates/component.html.hbs
Normal file
1
plop-templates/component.html.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
{{name}}
|
6
plop-templates/component.js.hbs
Normal file
6
plop-templates/component.js.hbs
Normal file
|
@ -0,0 +1,6 @@
|
|||
import {{properCase name}}Controller from './{{dashCase name}}/{{camelCase name}}Controller.js'
|
||||
|
||||
angular.module('portainer.{{module}}').component('{{camelCase name}}', {
|
||||
templateUrl: './{{camelCase name}}.html',
|
||||
controller: {{properCase name}}Controller,
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue