How to create new templates
October 17, 2016 ยท View on GitHub
In order to create new templates you just need to do the following.
Template files
- Create new folder with your
templateNameinto thetemplatesfolder. - Create you template files under your new template.
- Set your placeholders:
- Placeholders must have the following format
${param_name} - Placeholders are possible on files content as well as on folder/file names.
- Placeholders must have the following format
Template documentation
- Create a new folder called
.no-copied-configinto you template - Add there a description.txt file with a short description that clarifies what the template is for:
- This description will be show when running
./mg2-codegen.phar template:info <template>
- This description will be show when running
OPTIONAL
-
If your template requires some manual steps after the code is generated, you can document this info in:
.no-copied-config/after-generate-info.txt- This info will be displayed at the end of the code generation command. You can also use placeholders on this file.
-
If you want that your template executes other templates before, you can set dependencies in:
-
.no-copied-config/config.ymldependencies: 0: <template-name> 1: <template-name>
-
Example
You can check a template example here Template Samples
Important info
Built-in Properties
Following properties are automatically set:
vendorname-> calculated from registration.phpmodulename-> calculated from registration.phpCommentsCompanyNamecommentsUserEmailcommentsYear
Multicase properties
-
For all placehoders two versions with
Uppercase firstandlowercaseare created. That means, that for every praceholder there will be 2 created:-
vendorname = companyexample
-
Vendorname = Companyexample
-
modulename = examplemodule
-
Modulename = Examplemodule
-
customparam = somevalue
-
Customparam = Somevalue
-
-
Thanks to that, the user needs to enter only 1 value but 2 different placeholders can be used on the templates.