Giter Site home page Giter Site logo

Support XML Elements about gomponents HOT 7 CLOSED

maragudk avatar maragudk commented on June 19, 2024
Support XML Elements

from gomponents.

Comments (7)

markuswustenberg avatar markuswustenberg commented on June 19, 2024 1

I'm playing with an implementation here: https://github.com/maragudk/gomponents-xml/pull/1

Not sure how I'm going to keep code duplication down, but maybe it doesn't matter. Or maybe I should just incorporate it in this repo… (I'm thinking out loud.)

from gomponents.

markuswustenberg avatar markuswustenberg commented on June 19, 2024

Hi @tgrosinger . Hmm, yeah, the library is really geared towards HTML5 use, but I've hit the use case before. I have an SVG package in the repo which would potentially hit the same issue.

Maybe I could consider making an XML package that renders slightly differently, I'll think about that. I would think it would have more or less the same API, without the HTML-specific parts, and probably no helpers, so it would be pretty easy to implement.

from gomponents.

tgrosinger avatar tgrosinger commented on June 19, 2024

It's not very clean at all, but this change did fix the issue for me: https://github.com/tgrosinger/gomponents/commit/b8a83564c297b77523b7944ad5c97fbb1329ca13

I think if renderChild were exported it would be much easier to reduce the duplication. Then I might suggest creating an xml package as a sibling to the svg and html packages.

from gomponents.

tgrosinger avatar tgrosinger commented on June 19, 2024

Alternatively, this might also relate to #124 and possibly moving where the void element checking occurs and moving it out closer to the specific element type. That might be harder to do without changing the API though.

from gomponents.

markuswustenberg avatar markuswustenberg commented on June 19, 2024

@tgrosinger Both good points. For me, it's important that the focus of the library is HTML, and having something like XML support is nice, but not central to it.

I don't want to pollute the public API with XML-specific stuff that would confuse other users, but maybe I can pull the rendering logic into an internal package and thus have it available both from the xml and core package. That would also clean up the svg package, which similarly doesn't have void elements.

That actually seems like a feasible solution. I'll play around with it when I get some time, hopefully next week.

from gomponents.

tgrosinger avatar tgrosinger commented on June 19, 2024

Sounds great. Thank you very much for looking at this!

from gomponents.

markuswustenberg avatar markuswustenberg commented on June 19, 2024

@tgrosinger I played around with this a bit, but quickly ran into problems with import cycles when pulling out the rendering logic. I'm not currently sure about a path forward without breaking the API (not an option), exposing rendering logic in the API (not a huge fan of that, since the focus is definitely HTML and would be totally irrelevant to those consumers), or duplicating a lot of code (also not a huge fan of that). I'll think about it some more, and suggestions are also welcome. 😊

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.