-
Notifications
You must be signed in to change notification settings - Fork 62
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
Emit Unsafe.string_attrib for _-prefixed attributes in syntax ppxs to support non-standard attribute names #296
Conversation
FWIW, I've been using this in anger for a week or so, and it's working out quite nicely to emit htmx-flavoured HTML. Any thoughts on the approach? |
Sorry about the late response. Interesting escape hatch. Why do you need Since |
Oh, maybe I don't. I didn't think to (re)use I'll tweak that up and swap |
2e8b221
to
2b2e35b
Compare
I have updated my fork (and this PR) to:
|
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.
Nice work !
Could you adjust the documentation/tutorials for the ppx/jsx to mention this new feature ?
jsx/tyxml_jsx.ml
Outdated
replace (Posix.compile_pat "[A-Z]") ~f:(fun g -> "-" ^ Group.get g 0) string | ||
|> String.lowercase_ascii | ||
|> replace_string (compile @@ char '_') ~by:"-" in | ||
match exec_opt (Perl.compile_pat {|^(data_?|aria_?)(.+)|}) name with |
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.
Please put the compilation part at toplevel !
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.
Ah yeah I meant to do that before committing 🙃
I've updated to include top-level compilation of the necessary patterns, and added a section to the ppx/jsx docs. (I haven't been able to "test" the latter though, as I had trouble getting the wikidoc to build; Hopefully I didn't faff up the wiki documentation markup. 🤞 |
Thanks @cemerick |
Fixes #295
(also includes more generalized kebab-casing for attributes from jsx)