@@ -83,11 +83,11 @@ And some template files like this:
8383```
8484|- index.js // This file contains static code, e.g. starting a webserver and including ./api/index.js
8585|+ 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
8787 |+ 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.
8989```
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.
9191
9292In this example the generated directory structure will be like this:
9393```
@@ -101,6 +101,15 @@ In this example the generated directory structure will be like this:
101101 // (e.g. postUserLogin, getUserByUsername, putUserByUsername, deleteUserByUsername).
102102```
103103
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+
104113### Template file content
105114The generator passes the OpenAPI spec to template files, so all information should be available there.
106115In addition to that, the code generator adds a bit [ more data] ( #data-passed-to-handlebars-templates ) that can be helpful.
0 commit comments