|
| 1 | +# How to create new templates |
| 2 | + |
| 3 | +In order to create new templates you just need to do the following. |
| 4 | + |
| 5 | +## Template files |
| 6 | + |
| 7 | +0. Create new folder with your `templateName` into the `templates` folder. |
| 8 | +0. Create you template files under your new template. |
| 9 | +0. Set your placeholders: |
| 10 | + * Placeholders must have the following format `${param_name}` |
| 11 | + * Placeholders are possible on files content as well as on folder/file names. |
| 12 | + |
| 13 | +## Template documentation |
| 14 | + |
| 15 | +0. Create a new folder called `.no-copied-config` into you template |
| 16 | +0. Add there a description.txt file with a short description that clarifies what the template is for: |
| 17 | + * This description will be show when running `./mg2-codegen.phar template:info <template>` |
| 18 | + |
| 19 | +### OPTIONAL |
| 20 | + |
| 21 | +* If your template requires some manual steps after the code is generated, you can document this info in: |
| 22 | + * `.no-copied-config/after-generate-info.txt` |
| 23 | + * This info will be displayed at the end of the code generation command. You can also use placeholders on this file. |
| 24 | + |
| 25 | +* If you want that your template executes other templates before, you can set dependencies in: |
| 26 | + * `.no-copied-config/config.yml` |
| 27 | + |
| 28 | + ``` |
| 29 | + dependencies: |
| 30 | + 0: <template-name> |
| 31 | + 1: <template-name> |
| 32 | + ``` |
| 33 | + |
| 34 | +### Example |
| 35 | + |
| 36 | +You can check a template example here [Template Samples](../samples) |
| 37 | + |
| 38 | +## Important info |
| 39 | + |
| 40 | +### Built-in Properties |
| 41 | + |
| 42 | +Following properties are automatically set: |
| 43 | + |
| 44 | +* `vendorname` -> calculated from registration.php |
| 45 | +* `modulename` -> calculated from registration.php |
| 46 | +* `CommentsCompanyName` |
| 47 | +* `commentsUserEmail` |
| 48 | +* `commentsYear` |
| 49 | + |
| 50 | +### Multicase properties |
| 51 | + |
| 52 | +* For all placehoders two versions with `Uppercase first` and `lowercase` are created. That means, that for every praceholder there will be 2 created: |
| 53 | + |
| 54 | + * **v**endorname = **c**ompanyexample |
| 55 | + * **V**endorname = **C**ompanyexample |
| 56 | + |
| 57 | + * **m**odulename = **e**xamplemodule |
| 58 | + * **M**odulename = **E**xamplemodule |
| 59 | + |
| 60 | + * **c**ustomparam = **s**omevalue |
| 61 | + * **C**ustomparam = **S**omevalue |
| 62 | + |
| 63 | +* Thanks to that, the user needs to enter only 1 value but 2 different placeholders can be used on the templates. |
0 commit comments