-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
support HTML-like syntax #207
Comments
@slimsag if it's of any interest, with It's a very basic implementation for now and doesn't do any parsing of template fields (unlike your proposal). Further enhancements that I had in mind include:
|
This is brilliant. I have been using vecty only a bit and ended up having to use something custom specifically because some front end people spat the dummy about it. Dave has a HTML to vecty generator. https://github.com/dave/html2vecty Would this be useful ? |
Yes, I've wanted a templating alternative to Work in progress: Video about it: (UPDATE) Better video about it: No reason whatever this is has to be builtin to Vecty, too. |
Hi @slimsag and everyone! I just found out about Vecty today through the WebGL Go advent post. After trying to grasp the main ideas behind the code and design of Vecty, my understanding of it is that Vecty is essentially an intermediate representation (IR) for constructing, manipulating and accessing the DOM tree, with event handlers and type safety that are usually not present when writing HTML/JS/CSS. This is an attractive feature of Vecty. The other obvious part of Vecty that I except to be quite intricate is the tracking of what components require rerendering after updates, analogous to a scene graph I'd imagine but I haven't looked at any details. I looked at the docfest but the rendering docs are still a TODO ;) I tried to compile and play around with the Whisper Simulator by @divan who wrote the WebGL Go advent article, and as it so happens, one of the dependencies were not yet published so the build failed (divan/whispervis#1). The great benefit of having the code base use the After commenting out the various parts of the code that had to do with the simulator component, and rebuilding with In large part this is a huge tribute to and speaks well for the compositionability of Vecty. Taking a step back and reconsidering the scenario if the render components had used strings instead of the Vecty IR (i.e. the For these reason, and more generally for my personal belief that constructing a first-class IR representation is of huge value! Then, you can have more human readable, quicker to write representations that may be converted to this IR representation (using e.g. html2vecty). It's funny though, I kind of consider the HTML code when written in Vecty In either case, I wanted to raise this observation, and also present some view from someone new to Vecty. Perhaps not the kind of user you would target for, but as Vecty currently stands, I very much consider it a huge improvement over regular ways of developing front-end code. (and in my mind, the proposal to change Wish you all happy continued exploration, and thanks for working on this! I do believe Vecty has the potential to make a well-needed breakthrough in how we develop front-end code. In large part, as it's so easy to mix front-end and back-end code in the same development environment. Following the predetermined way of other frameworks is good in the sense of more easily converting previous user bases. However, to creating something new and quite unique and hopefully influential, stepping outside of that comfort zone is great and you are already well headed down that path. Continue and see where it leads! :) Cheers, Edit: and just to show how effortless it was to remove the component related to the simulator, I uploaded the full patch required as a Gist https://gist.github.com/mewmew/b8d7ac088471ffa9b4655d3416437f9c (applied on divan/whispervis@c395bc3) |
@mewmew, just to note, it was totally my fault – I just forgot to make repo public, fixed now – but I'm glad it contributed to some fruitful discussion and ideas. |
I think I like this proposal, but we should be careful about the distinction between properties and attributes. This is particularly important in the context of custom elements. See all the talk of elements vs attributes in https://custom-elements-everywhere.com/. In the old syntax, it was explicit and in the new syntax, it appears to be implicit. Lit-html recently put some thought into this during their own syntax overhaul. The relevant part of the conclusion of that discussion was
Source: lit/lit#399 (comment) I'm not saying that an implicit property/attribute heuristic is necessarily a bad thing, but in general, Go prefers to be explicit, so going in the other direction merits careful consideration. |
I personally really like the If you start to add HTML in Go files, you still lose a part of the Go tooling and that will add a need for VSCode, IntelliJ plugins and complicate the all thing. This has been a determining factor for me to chose between |
Forewarning: This is just a thought I've had for a long time, but hadn't put into words. This is not a statement of "I intend to do this" but rather a place to discuss this topic.
While I am personally a fan of
elem.Div
et al., I notice that others are very much fans of HTML-like syntax akin to jsx and have gone out of their way to create "JSX for Go" e.g. https://github.com/8byt/goxThe primary drawback of putting HTML syntax inside of a language that did not originally support it, is that you lose all tooling because it is fundamentally a drastic syntax change. You would lose
gofmt
,goimports
, syntax highlighting in your editor, and many others. In JavaScript, tooling had to adapt to support this syntax.I've long had an idea for how we could solve this without losing any existing Go tooling. The idea is quite simple: just place the HTML in a Go string literal. For an example of what this would look like, consider this code:
With this new syntax, it would become:
The benefit of such an approach is that:
The questions that doing this would raise:
elem.Div
etc. syntax?The text was updated successfully, but these errors were encountered: