-
Notifications
You must be signed in to change notification settings - Fork 136
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
#225 JS html to j2html code generator via kotlin multiplatform #226
base: master
Are you sure you want to change the base?
Conversation
I used kotlin multiplatform to write the converter so that it's in a language that is type-safe, null-safe, and generally nice to work with while able to compile to javascript The structure of src, with commonMain, commonTest, jsMain, jsTest, jvmMain, and jvmTest is because kotlin multiplatform structures the code to share some of it between platforms (in this case jvm and javascript), and to have some platform specific code for each target To generate the javascript, launch I used gradle instead of maven because that seems to be the standard for kotlin multiplatform projects, and I could not find any information on how to do the same in maven. It didn't need to be coupled to the rest of the maven structure anyway because while you can be called from and you can call java code from kotlin multiplatform, you can only call it from the jvm target, not from the javascript target I included a quick and dirty index.html file that calls the converter. To play around with the converter, the easiest way is to open the html-to-j2html folder in VSCode, right click on index.html, Open with live server. The converter should be operational in the opened browser Launching |
The actual converter logic is in commonMain, in Converter.kt, it uses the library KSoup to read the html. How each attributes is supported in configured in SupportedJ2HtmlAttributes.kt, this file may need to modified in the future if new attributes are supported or change types or something. I also wrote a bunch of unit tests in ConverterTests in commonTest, using snippets I found online, tweaking the converter until the produced code seemed acceptable. You can have a good look at the expected outputs to see if the generated code is the way you'd want it to be. Feel free to ask about any unclear parts |
Is this waiting for @sembler or me? |
Is this question directed at me ? I wouldn't know, I suppose that's for you and @sembler to decide |
any news ? |
Sorry @PancakeInvaders2, life is sort of busy at the moment, and this pull request is pretty large. When I said I could help get this added to the website I was picturing adding a JS library to the website and calling it with some input, not adding a whole new module of a thousand+ lines. I originally handed this project over to @sembler some years ago, but he has become quite busy too. I'll try to help you get it live, but I don't see any JS library in the PR, could you outline how this can be created and plugged into the website? |
I understand, the purpose of the index.html was to show how this could be used in the website Maybe it would be easier if I put the generator in a separate project, maintain it myself, and put it on npm or something so you can use it as you please |
I saw the HTML file, but not the actual |
No description provided.