Code Monkey home page Code Monkey logo

Comments (10)

gedw99 avatar gedw99 commented on June 25, 2024 1

Lsp for hyperscript would be fantastic . Maybe it’s possible to do with the templ lsp Server ?

from templ.

a-h avatar a-h commented on June 25, 2024

Thanks for raising the issue, and for using templ!

The _ attribute should be supported as of the release I tagged today, thanks to @joerdav's PR - https://github.com/a-h/templ/pull/107/files#diff-ad6799840c66a0c4c053972d865d82099e1862aaa2c073e84b5e1f27f4e127c4

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 _={ `whatever` } in the interim until we get that sorted.

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. 😁

from templ.

1cg avatar 1cg commented on June 25, 2024

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

from templ.

gedw99 avatar gedw99 commented on June 25, 2024

Yeah I agree about the insanity.

i am playing around with the idea of building a golang based htmx / Turbo System . So then templ and it’s LSP would fit in with it.

The reason is because it’s not just html that could do with a bit of htmx magic . The big sky team are doing a similar thing for React Native btw. They can it Hyper. It’s on GitHub.

my motivation is to use gio which can run on web, desktop and mobile . The markup is xml based. So then you can see how a nice htmx style System would make it easy to do the gui updates ..

The markup is based on the zudecken format. Then just add templ and htmx ( the golang Version :) ) and your cooking with gas as they say.

from templ.

a-h avatar a-h commented on June 25, 2024

@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.

from templ.

1cg avatar 1cg commented on June 25, 2024

i will die on the recursive descent hill

looking forward to the talk, would love to get a hyperscript lang server going!

from templ.

acmacalister avatar acmacalister commented on June 25, 2024

Thanks for raising the issue, and for using templ!

The _ attribute should be supported as of the release I tagged today, thanks to @joerdav's PR - https://github.com/a-h/templ/pull/107/files#diff-ad6799840c66a0c4c053972d865d82099e1862aaa2c073e84b5e1f27f4e127c4

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 _={ `whatever` } in the interim until we get that sorted.

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. 😁

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!

from templ.

joerdav avatar joerdav commented on June 25, 2024

@acmacalister Any luck? Did it work with the latest version?

from templ.

acmacalister avatar acmacalister commented on June 25, 2024

@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.

from templ.

a-h avatar a-h commented on June 25, 2024

#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

from templ.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.