@@ -83,11 +83,11 @@ And some template files like this:
83
83
```
84
84
|- index.js // This file contains static code, e.g. starting a webserver and including ./api/index.js
85
85
|+ api/
86
- |- index.js // This is a static template, it contains placeholders that will be filled in, e.g. includes for each file in routes
86
+ |- index.js.hbs // This is a static template, it contains placeholders that will be filled in, e.g. includes for each file in routes
87
87
|+ routes/
88
- |- $$path$$.route.js // This file will be generated for each operation and contains skeleton code for each method for an operation.
88
+ |- $$path$$.route.js.hbs // This file will be generated for each operation and contains skeleton code for each method for an operation.
89
89
```
90
- The first important thing to notice here is the variable notation in ` $$path$$.route.js ` . It will be replaced by the name of the path.
90
+ The first important thing to notice here is the variable notation in ` $$path$$.route.js.hbs ` . It will be replaced by the name of the path.
91
91
92
92
In this example the generated directory structure will be like this:
93
93
```
@@ -101,6 +101,15 @@ In this example the generated directory structure will be like this:
101
101
// (e.g. postUserLogin, getUserByUsername, putUserByUsername, deleteUserByUsername).
102
102
```
103
103
104
+ ### Template file extensions
105
+ You can (optionally) name your template files with ` .hbs ` extensions, which will be removed when writing the generated
106
+ file. e.g. ` index.js.hbs ` writes ` index.js ` . ` index.js ` would also write to ` index.js ` , if you prefer to omit the hbs
107
+ extension.
108
+
109
+ The only case where the ` .hbs ` extension isn't optional would be if you are writing handlebars templates with the
110
+ templates. In that case the the template would need the extension ` .hbs.hbs ` . ` usertpl.hbs.hbs ` writes ` usertpl.hbs `
111
+ (but ` usertpl.hbs ` as a source would write ` usertpl ` with no extension).
112
+
104
113
### Template file content
105
114
The generator passes the OpenAPI spec to template files, so all information should be available there.
106
115
In addition to that, the code generator adds a bit [ more data] ( #data-passed-to-handlebars-templates ) that can be helpful.
0 commit comments