-
Notifications
You must be signed in to change notification settings - Fork 0
Templates
Template is just a folder with control script and special formed prhttps://github.com/notificationsoject files. Template files have access to project configuration file and can read them to use during project generation. Configuration parameters are substituded in right places and finally you get a final project file. It's two kinds of templates. Project templates and FlappyTools templates. FlappyTools templates are used to generate base for you next work. For example, when you create Unity3d project, you can choose 2d or 3d project will be created, depending of selection different configuration will be applied. Similar way you select type of project in any other IDE project wizards. Project templates are used for generation of desired IDE project.
In the root of template you can find two files:
- generator.js - Entry point of project generation. Generator can prepare context and functions for using in template files. Also it can generate project files without templates, search and use other templates if needed.
- default.json - Default configuration of the project. All parameters of default configuration can be overridden in project configuration files. Usually, in here also placed template files itself in separate directory. Template files include js injections which can modify them in same way as PHP injections modify php files in order to generate html.
Template file is just a usual text file with js injections. For example:
cmake_minimum_required(VERSION 3.0) project ([= config.name =]) ...
As you can see, inline code injections are surrounded by "[=" and "=]" markers. It's same as "= ?>" in PHP. Another example:
target_include_directories ([= config.name =] [% for (let i in config.cxx.header_dirs) { %] "[= normalize(config.cxx.header_dirs[i]) =]" [% } %] )
Here is example of generation list of include directories for CMake. It's combination of inline and control injections. Control injections are surrounded by "[%" and "%]". You can print code from control injections using method "output()"