Comments (9)
Hi @erikd234 . I've thought about doing a converter from HTML to gomponents, but haven't tried it yet. I think that could be an interesting little project!
What I usually do when I am in this situation is to put the relevant HTML in files next to your .go component files, embed them with go:embed
, and then use g.Raw
to render them directly. The resulting overall component sometimes looks a bit odd, but it works just fine. Then you can selectively replace HTML with gomponents where needed.
Would that work for you?
from gomponents.
Note to self: there's an HTML parser: https://pkg.go.dev/golang.org/x/net/html
from gomponents.
Hi.
I started using Gomponents with Tailwind and I started hating rewriting HTML classes into Gomponents code.
So I wrote a small helper tool. Also, I plan to add exposed api for sending files to server and returning responses via endpoint. Later I will also add CLI tool
http://htg.piotrkowalski.me/
It runs on my local computer so may not be 24/7, feel free to use it. I dont handle most of gomponents elements and attributes now. Right now, I mostly take the html node data and uppercase the first letter. The custom HTML to gomponents can be easily added. WIll do it if I come accross some problem myself.
You can check source code here
https://github.com/PiotrKowalski/html-to-gomponents
from gomponents.
@PiotrKowalski , that is so super cool! :D Could you host it somewhere that can take some traffic? Then I'll link to it from the gomponents website.
from gomponents.
@markuswustenberg
Thanks for the acknowledgment
I will look into it, but for ~one week I wont be able to do anything more in this matter.
And also, it is like 0.0.1 version. I need to add more gomponents structs there. For example, I am not able to create g.Attr() node automatically right now.
This converter handles like 80% of manual labour, remaining 20% needs to be done manually by dev for now.
WIll look into hosting next week
from gomponents.
@PiotrKowalski no stress, it comes up when it comes up. 😊 Let me know!
from gomponents.
Hi @markuswustenberg
I made little fixes on my tool. It should generate g.Attr and g.El for weird edge cases.
Also, I put this tool on gcloud with whole cicd pipeline.
You can get a link in the description of repository
https://html-to-gomponents-4r3ru275tq-ew.a.run.app/
For now I will keep it that way. Later I will move to better domain
from gomponents.
@PiotrKowalski excellent, thank you for the update!
from gomponents.
Related Issues (20)
- Merge multiple occurrences of the `class` attribute HOT 5
- Proposal: Re-export packages with shorter names (g, h, c) HOT 3
- Inline if with nil pointer HOT 8
- Why can't a group be rendered? HOT 11
- Add lib to awesome Go HOT 1
- Remove fmt.Stringer support? HOT 3
- Handling internationalization HOT 9
- trigger an error on duplicate attributes HOT 3
- Make Group renderable
- Proposal to Add String Rendering Method to Node Interface HOT 5
- Label can be an attribute as well HOT 2
- Missing list attribute HOT 1
- Figure out what can be done about name collisions between elements and attributes HOT 4
- Add new `[type]` links to godocs
- Drop support for pre Go 1.18? HOT 3
- Perhaps we can take inspiration from HOT 6
- JS Ternary like HOT 1
- Add `cite` attribute
- Is it possible to modify an existing gomponent?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gomponents.