-
-
Notifications
You must be signed in to change notification settings - Fork 305
htmx _= attribute for hyperscript #122
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
Comments
Thanks for raising the issue, and for using templ! The However, it won't completely make working with Hyperscript in templ brilliant, because @joerdav also mentioned the need for multi-line attribute support in #115 He's suggested that it's possible to use the Go expression attribute For "constant" attributes templ currently just parses all text until the next double quote value, so another related issue is the use of single quotes - #116 I'm working on a conference talk for Gophercon London which will take up all my spare time for a few weeks, but then I'll be able to focus back on feature development for templ. I'm hoping it will help @1cg write a Language Server for Hyperscript. 😁 |
given how insane the hyperscript parser/grammar (same thing) is, I'd say using the actual parser (in js) for the language server would be the best option if at all possible |
@1cg I'll happily give you a preview of my talk in a week or so in exchange for feedback! It explains how to make a hello world language server from scratch (in Go, but that's just detail), how the protocol works at a low level, then goes up through the abstractions until you've got a real language server. I show making one for https://cooklang.org/ And then I go into a bit of detail on how the templ one works. I think the main thing is that it really helps if the parser you've got produces file positions of where errors are, and produces an object model where you can go from a a file position to something in your code. For example, in templ, you can go from a file position (line 3, col 2) and find the expression that you're in. I did try out using a PEG parser, but I ended up wanting a lot more control over error messages too, so I've stuck with a hand-written one that lets me maintain a map of file positions to components in the component tree. |
i will die on the recursive descent hill looking forward to the talk, would love to get a hyperscript lang server going! |
Certainly. Thanks for the hard work in making it. Working on a small project at work and wanted to something I could embed templates and use HTMX with. I'll test it again from the tip and see what it looks like. Let me know if there is anything I can do to help or test out. LSP for hyperscript would be awesome! Can't imagine what the parser/grammar will look like for that! |
@acmacalister Any luck? Did it work with the latest version? |
@joerdav, yes! Worked great on the latest version. Used the string literal workaround for some long form htmx calls. Thanks for the changes. Happy to provide snippets of the code for samples if that is helpful for other folks looking into this. |
#115 was just closed in 5b810fa by @joerdav and released in > v0.2.316 @acmacalister - I think this is resolved. Feel free to reopen if not. If you think something is missing in the docs at https://templ.guide that would be useful to people, perhaps you could add a page? The docs are at https://github.com/a-h/templ/tree/main/docs/docs |
Howdy. Just wanted to drop by and say thanks for making this. Been trying some htmx and was looking for a nice templating language.
Currently, the parser throws an error if I add the htmx
_=
attribute to any html tag. The error for reference:Error
Example to Reproduce
https://htmx.org/examples/confirm/
My code
My current workaround is to just move this code into a
This isn't idiomatic Hyperscript and it is hard to scope the handlers to the proper element.
The text was updated successfully, but these errors were encountered: