Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for any template engine #25

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pitpit
Copy link
Contributor

@pitpit pitpit commented Jun 20, 2019

This is a PR I wrote because I need to reuse a template that I already made on nunjucks

It decouples templating and generator in a clean way using jstransformer.

I think it could be useful for other people.
I'll publish my template based on nunjucks in another PR

  • use jstransformer to render template
  • handle specific handlebars partials and helpers with an in-directory config system (.bootstrap.js)
  • customizable target file renaming to work with any template engine (myFile.md.hbs -> myFile.md)
  • customizable files ignore list to work with any template engine
  • documentation about how to install another template engine in README.md

@pitpit pitpit force-pushed the feat/multi-template-engines-support branch from b749e5a to fce62b9 Compare June 21, 2019 12:45
@fmvilas
Copy link
Collaborator

fmvilas commented Jul 1, 2019

I think this is an interesting concept to explore. I'm currently working more on the https://github.com/asyncapi/generator package (similar to this one but for AsyncAPI) and this is interesting. How difficult do you think it would be to migrate and test the whole library to support multiple template engines?

@pitpit
Copy link
Contributor Author

pitpit commented Jul 8, 2019

Hi @fmvilas I test it with jstransformer-nunjucks using this PR as a base and it actually works well now. Do you want me to push another PR as an example in order you to try it ?

How difficult do you think it would be to migrate and test the whole library to support multiple template engines?

What do you mean by "test the whole library" ? Unit testing ?

@fmvilas
Copy link
Collaborator

fmvilas commented Jul 8, 2019

A PR with an example would be appreciated, thanks!

And by testing I mean unit or integration tests. Just curious, not saying it should be done now. Thanks!

@pitpit pitpit mentioned this pull request Jul 8, 2019
@pitpit
Copy link
Contributor Author

pitpit commented Jul 8, 2019

@fmvilas here's a draft PR with nunjucks support #26

About the tests: we could have some tests using the same openapi spec and two different templating engine, two templates collections supposed to generate the same markdown and check that the output actually match.
Or easier, dumping the openapi specs in json through the two template engines and check that the output in json match the input. That will only check that the engines are well linked and bootstrapped but that's a good beginning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants