-
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
Attributes per tag PoC #117
base: master
Are you sure you want to change the base?
Conversation
If we're really doing this, then I think it should be
|
I like that form too, but there will be a lot more code to implement (every tag arrtibute will be a delegate to base class). |
I know, I am bit worried about the amount of code, but I think it's a better solution. Create a poc and we'll see how it looks. |
I have updated the PR |
Yeah, we can't maintain this. We need to find a way to do this more cleverly (interfaces?), or just generate the code 🤔 |
My first thought was a code generator |
Maybe annotations can be used? I've never used them myself, but I know a lot of libraries use annotations to generate code. |
For sure there are plenty of java code generators. |
Have you guys seen how kotlinx.html has done this: https://github.com/kotlin/kotlinx.html/wiki/Getting-started Essentially, they have got some source files representing relevant parts of the HTML 5 spec: https://github.com/Kotlin/kotlinx.html/tree/master/generate/src/main/resources. I imagine this either comes from an IDE (Eclipse?) or Mozilla? This means they don't need to maintain this datasource themselves. Then their generate module parses this and coverts it into the Kotlin library. Not sure if this PR is still being worked on? This seems like a massive but hugely useful change. @tipsy do you want your project to go down this route or do you think this would be better attempted in a different project? If we were to do it in this project, I would try and do so in small steps. So first thing would be to parse the datasource and then see if I could get it to generate just the methods that already exist in TagCreator. JavaPoet seems to be a highly recommended code generator. |
I wouldn't mind, I think it's a good approach. I have other projects which I consider higher priority though, so it would have to be up to the community to implement it. I can help with discussion/code reviews. |
is this still being worked on? |
No one is working on this issue. I'm happy to review if the PRs are easily reviewable :) |
PR is out ! |
Build is not passing, just take a look at the code.
This change will add an ability to use API in the following way:
This type safe way to set attributes will force developer to use only proper attributes for HTML tags.
We could also remove methods that allow attribute names as
String
s.Also
Attr
s constants can be removed and changed toenum
s likeAAttribute
.The predefined attribute accessors from
Tag
should also be removed because they allow to set improper attributes for HTML tags.