Open WendellAdriel opened 1 year ago
Thanks for the review @jdreesen! I made the changes you pointed out and also added a new test case to test that when registering an invalid renderer an exception is thrown! 💪🏼
@xiCO2k @nunomaduro I think the PR is now looking good for a final review
I didn't add in the PR but if you think it could be something useful I can create a function registerRenderer
that can be imported and used like the style
function that will wrap the register method from the ElementRenderer
class so I can mark the ElementRenderer
as an internal class.
I didn't add in the PR but if you think it could be something useful I can create a function
registerRenderer
that can be imported and used like thestyle
function that will wrap the register method from theElementRenderer
class so I can mark theElementRenderer
as an internal class.
I added the registerRenderer
function now, marked the ElementRenderer
class as internal and updated the test suite to use the registerRenderer
function.
I saw that Termwind has some default renderers for some elements:
TableRenderer
PreRenderer
CodeRenderer
The purpose of this PR is to allow users to register Custom Renderers if they want. This can be a nice addition for developers that want to create plugins, so they can create their own custom renderers.
The general idea is to have a new contract
Renderer
that must be implemented for all renderers and the actual render will be done by the new classElementRenderer
that can be used to register new renderers and to use the registered renderers to render the content.I'm marking this as a Draft because I still need to know if this is something that you want to have in the project and if so I can work on modifying anything that's not "compatible" with what you're thinking for the project.
If this is not something you want in the project feel free to decline this, but if you think this can work, I'll be happy to work on any changes needed to have this merged. 😉 💪🏼 🔥