You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I generate API front-end code using typescript-fetch generator. Its templates are written in Mustache engine. I do my best editing templates to get the appropriate code, but since no logic is supported by Mustache, and I'm extremely limited. I cannot even write a simple if!
to build some custom type, array or enum. IIUIC, the only way to achieve this, is to edit the generator's java code to add an auxiliary boolean variable — e.g. isModelMyModel — to then use it as {{#isModelMyModel}}...{{/isModelMyModel}}.
This task could have been easily solved by using a templating engine which has a little more sense than Mustache in this particular case. And here comes Handlebars, hurray!
But as far as I see from googling the only way to use it is to completely switch the engine using -e generator option. So there is no such an option as combining Mustache and Handlebars. And since all the openapi generators are written in mustache we're still deprived of HBS, no matter how good it is. From the other side, rewriting all the templates from scratch just doesn't have any sense because Mustache already makes it job well... except where it doesn't.
Which leads to one obvious and most reasonable solution of this problem: all the template engines must be supported at once. User just provides the order of preference.
The text was updated successfully, but these errors were encountered:
@OnkelTem we won't be mixing Mustache and Handlebars, as this will add confusion (especially for template inclusions). We've actively worked to avoid allowing Mustache and Handlebars from being colocated and compiled through the same engine.
Luckily, Handlebars can process pretty much all of Mustache syntax, excluding custom mustache lambdas. This means converting to handlebars in some cases is as easy as changing the file extension.
For this scenario, if you do want Handlebars and Mustache compilation, I'd recommend creating a custom engine and applying your preferred logic within the adapter. You can see an example I created for the Pebble templating system: https://github.com/jimschubert/pebble-template-engine-adapter You could use our built-in handlebars and mustache adapters, and this gives you the added flexibility of adding customizations to each engine.
Uh oh!
There was an error while loading. Please reload this page.
Consider this regular scenario.
I generate API front-end code using
typescript-fetch
generator. Its templates are written in Mustache engine. I do my best editing templates to get the appropriate code, but since no logic is supported by Mustache, and I'm extremely limited. I cannot even write a simpleif
!For instance, I cannot do:
to build some custom type, array or enum. IIUIC, the only way to achieve this, is to edit the generator's java code to add an auxiliary boolean variable — e.g.
isModelMyModel
— to then use it as{{#isModelMyModel}}...{{/isModelMyModel}}
.Sure I can do:
which would turn into a bunch of:
and it would be terrible.
This task could have been easily solved by using a templating engine which has a little more sense than Mustache in this particular case. And here comes Handlebars, hurray!
But as far as I see from googling the only way to use it is to completely switch the engine using
-e
generator option. So there is no such an option as combining Mustache and Handlebars. And since all the openapi generators are written in mustache we're still deprived of HBS, no matter how good it is. From the other side, rewriting all the templates from scratch just doesn't have any sense because Mustache already makes it job well... except where it doesn't.Which leads to one obvious and most reasonable solution of this problem: all the template engines must be supported at once. User just provides the order of preference.
The text was updated successfully, but these errors were encountered: