Giter Site home page Giter Site logo

Comments (9)

markuswustenberg avatar markuswustenberg commented on September 23, 2024

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.

markuswustenberg avatar markuswustenberg commented on September 23, 2024

Note to self: there's an HTML parser: https://pkg.go.dev/golang.org/x/net/html

from gomponents.

PiotrKowalski avatar PiotrKowalski commented on September 23, 2024

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.

markuswustenberg avatar markuswustenberg commented on September 23, 2024

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

PiotrKowalski avatar PiotrKowalski commented on September 23, 2024

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

markuswustenberg avatar markuswustenberg commented on September 23, 2024

@PiotrKowalski no stress, it comes up when it comes up. 😊 Let me know!

from gomponents.

PiotrKowalski avatar PiotrKowalski commented on September 23, 2024

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.

markuswustenberg avatar markuswustenberg commented on September 23, 2024

@PiotrKowalski excellent, thank you for the update!

from gomponents.

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.