-
Notifications
You must be signed in to change notification settings - Fork 54
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
Interface for template engines #251
Interface for template engines #251
Conversation
@mfiumara thanks for the effort in many cases the engines have additional functionalities, so i think we have to export them as well for the check if the engine complies with the interface i would suggest we use "embedded interfaces" or "typechecks in test or real code". |
Hi, Thanks for the feedback I'll come up with a refinement of this draft later tonight by embedding interfaces. I see what you mean and we're indeed not exporting all functions of the engine right now. |
Hey I've added an embedded interface for Pug such that all functions are exported now. For the remainder of the engines I'd go through all of them in a similar fashion. Let me know if anything else is required before I go through with that. Perhaps I should move the function comments inside the interface definition? Or copy them over? |
068bddb
to
a7d4e29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think internal dir is not good idea. Someome else may want to use this interface in their projects. It can be template.go in the project root like how it's on storage repo
Yes, good point |
@efectn Moved to root into |
On another note I see that a lot of the functions are practically the same for all Engines. If we could make some or all of the fields of the Engine struct public we could also embed the struct and define most of the methods once for all of the engines. It will save a lot of code and will be easier to add new engines. Let me know if that's a good idea or not, it does mean the members will become public which perhaps is not what we want. |
Agree with you. It's worth to try |
@efectn I've done the following:
I don't see the commit here yet in the PR, I'm not too familiar with Github but perhaps that takes some time to appear. |
17bbb27
to
791f0da
Compare
Added second Engine Mustache to illustrate further. I should be able to do the rest fairly quickly let me know if this is the way forward. |
I think I'm done @efectn. Would be great if you can have a look. I additionally want to remove all redundant tests and move them to internal, that should save some unnecessary tests. |
Can you check hound comments @mfiumara |
@efectn Done |
@mfiumara can you resolve the conflicts, i removed parse() from engines |
e99ec91
to
f2c9833
Compare
@efectn Fixed conflicts, rebased and squashed commits. |
This commit introduces a common interface for template engines. Any new template engines should adhere to the Engine interface in order to have a common API. The internal struct can be embedded to promote the default functions into a specific template engine in order to reduce boilerplate. The struct definition should only be used internally, whereas the interface can be used externallly. Fixes issue gofiber#248
1eb6d6c
to
77b204c
Compare
Hi @efectn could this be merged? I had to resolve conflicts again due to other changes being merged. |
The changes are OK to me but we should wait for one more review. @ReneWerner87 will review the PR when he is free. |
@mfiumara very good work
this fact is unfortunately not quite covered try to explain it again |
By the way, if you made the last change, do we have to count up the major because there is a breaking change included here ? |
Thanks for the feedback @ReneWerner87. At the moment there are no extra methods being exposed by any of the engines as far as I can tell, which is why I'm returning the same interface for all the engines and have removed the interfaces defined in the template engines. If you want I can define the interface separately again for each template engine and return that in the Regarding backwards compatibility, I'm not 100% sure how or when this package breaks backwards compatible as I'm not aware how external packages depend on this one. I can bump the version but not sure how you go about this in this project, maybe it's best if I leave that up to you to do once any other changes are agreed upon. |
- remove the internal folder, because the use is not possible from the outside - replay the original engine to use engine specific code extensions - renaming of core structs and interfaces
- correct some comments
- correct some comments
Initial draft for having interfaces for template engines. This can reworked and is open for discussion.
applies to #248