{"action":"created","issue":{"url":"https://api.github.com/repos/tipsy/j2html/issues/121","repository_url":"https://api.github.com/repos/tipsy/j2html","labels_url":"https://api.github.com/repos/tipsy/j2html/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/tipsy/j2html/issues/121/comments","events_url":"https://api.github.com/repos/tipsy/j2html/issues/121/events","html_url":"https://github.com/tipsy/j2html/pull/121","id":336613740,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4MDI0MDQw","number":121,"title":"Generate tags from JSON file","user":{"login":"mwanji","id":58760,"node_id":"MDQ6VXNlcjU4NzYw","avatar_url":"https://avatars3.githubusercontent.com/u/58760?v=4","gravatar_id":"","url":"https://api.github.com/users/mwanji","html_url":"https://github.com/mwanji","followers_url":"https://api.github.com/users/mwanji/followers","following_url":"https://api.github.com/users/mwanji/following{/other_user}","gists_url":"https://api.github.com/users/mwanji/gists{/gist_id}","starred_url":"https://api.github.com/users/mwanji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwanji/subscriptions","organizations_url":"https://api.github.com/users/mwanji/orgs","repos_url":"https://api.github.com/users/mwanji/repos","events_url":"https://api.github.com/users/mwanji/events{/privacy}","received_events_url":"https://api.github.com/users/mwanji/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-28T13:07:19Z","updated_at":"2018-06-28T17:10:38Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/tipsy/j2html/pulls/121","html_url":"https://github.com/tipsy/j2html/pull/121","diff_url":"https://github.com/tipsy/j2html/pull/121.diff","patch_url":"https://github.com/tipsy/j2html/pull/121.patch"},"body":"Inspired by @mkopylec and #117 , here is a slightly different approach.\r\n\r\nThe way I see it, the generator would be in a maven plugin, so that the resulting code would be in the generated source folder and no-one would try to edit it.\r\n\r\nThe project itself would contain the configuration file (in this POC, it's JSON). This makes it easy to add tags and attributes, and also to customise the methods. For example, I used an \"empty\" field to output methods that don't take a value. Here's an example of the two kinds of output, where autoplay is empty and controls is not:\r\n\r\n![image](https://user-images.githubusercontent.com/58760/42035958-6d5a3b22-7ae4-11e8-8ed0-3d44b19701da.png)\r\n\r\nHere's what the config file looks like:\r\n```json\r\n{\r\n    \"tags\": [\r\n        {\r\n            \"tag\": \"a\",\r\n            \"attrs\": [\r\n                \"href\",\r\n                \"charset\"\r\n            ]\r\n        },\r\n        {\r\n            \"tag\": \"video\",\r\n            \"attrs\": [\r\n                { \"name\": \"autoplay\", \"empty\": true },\r\n                \"controls\", \"height\", \"loop\", \"muted\", \"poster\", \"preload\", \"src\", \"width\"\r\n            ]\r\n        }\r\n    ]\r\n}\r\n```\r\nYou can see the output for yourself by running the main method in TagCreatorCodeGeneratorFromJson"},"comment":{"url":"https://api.github.com/repos/tipsy/j2html/issues/comments/401107366","html_url":"https://github.com/tipsy/j2html/pull/121#issuecomment-401107366","issue_url":"https://api.github.com/repos/tipsy/j2html/issues/121","id":401107366,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTEwNzM2Ng==","user":{"login":"mwanji","id":58760,"node_id":"MDQ6VXNlcjU4NzYw","avatar_url":"https://avatars3.githubusercontent.com/u/58760?v=4","gravatar_id":"","url":"https://api.github.com/users/mwanji","html_url":"https://github.com/mwanji","followers_url":"https://api.github.com/users/mwanji/followers","following_url":"https://api.github.com/users/mwanji/following{/other_user}","gists_url":"https://api.github.com/users/mwanji/gists{/gist_id}","starred_url":"https://api.github.com/users/mwanji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwanji/subscriptions","organizations_url":"https://api.github.com/users/mwanji/orgs","repos_url":"https://api.github.com/users/mwanji/repos","events_url":"https://api.github.com/users/mwanji/events{/privacy}","received_events_url":"https://api.github.com/users/mwanji/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T17:10:38Z","updated_at":"2018-06-28T17:10:38Z","author_association":"CONTRIBUTOR","body":"Yes, the plugin would be a separate artifact. I'll have an example repo up shortly.\r\n\r\nWould it be possible to change the use of Attr.addTo(Tag, ShortForm) to something like tag.with(ShortForm)? I currently can't figure out how to get the generics to work and changing that would make it a lot easier.\r\n\r\nAlso realising a lot of TagCreator's implementation would have to change... What would you think of generating TagCreator in the same way as the ContainerTag sub-classes, so that hand-written and generated code are no longer mixed together in one class?"}}
{"actor":{"display_login":"mwanji"}}