Open piotrm0 opened 2 years ago
Hi @piotrm0 thanks so much for feedback.
You are kind of correct on this and I was going to address it by documented namepacing.
However the only place I've seen it could be an issue might be django users.
(If you don't require a parser, the lightweight htmlx repo has everything moved to a 'tags' package. *undocumented) https://github.com/byteface/htmlx/
However the issue here (in domonic) is actually 3 fold.
There's the built in html i wanted to avoid as it has the escape package many people would want.
there an 'html' element,
as well as the module name.
The only way I could think to get around it was to change the module name or document usesage for those that want namespacing, which I wish I'd done now as I spent a few hours investigating then never posted the reuslts after I figured out the same as what you arrived at. I should have realised this would be useful to tell people.
import domonic as html
which only works as a fluke due to the core init file import the html module. so you are correct in there's an issue and also great you found the same workaround. As for a solution I think documenting namespace useage high up in the readme is all I can think of without breaking backwards compatibility. I had pondered on this before.
I actually considered changing html module to tags for v1. but still not sure how that would go down. had meant to test the concept more in htmlx first.
hmmm i wonder if a module called tags that imports html would work?. specifically for namespacing. happy to hear your thoughts if you have any ideas.
A module "tags" or "tag" anything else informative that would let us write "tag.br()" instead of "br()" using the star import would solve my problem.
I did have another idea which was to not import the html element in domonic root. But that would stop me from being able to do from domonic import *
I've added the tags package and imported all from html into it. I think this now does what we want?...
import domonic.tags
print(domonic.tags.h1)
# or
import domonic.tags as tags
str(tags.div)
# or
import domonic.tags as html
print(html.span)
Let me know if this is ok. Should be there on the 0.9.9
I did have another idea which was to not import the html element in domonic root. But that would stop me from being able to do
from domonic import *
I've added the tags package and imported all from html into it. I think this now does what we want?...
import domonic.tags print(domonic.tags.h1) # or import domonic.tags as tags str(tags.div) # or import domonic.tags as html print(html.span)
Let me know if this is ok. Should be there on the 0.9.9
Please come back the library is incomplete and i need domonic
hi @nacho00112 . apologies I've been a little busy. Which feature in particular are you interested in?
hi @nacho00112 . apologies I've been a little busy. Which feature in particular are you interested in?
I tried domonifying the google.com html source and it didn't worked
Hi, I'm trying to get a handle on domonic.html module via
import domonic.html
orfrom domonic import html
as opposed tofrom domonic.html import *
(to be able to dohtml.span("hello")
instead ofspan("hello")
). However,domonic.html
is ambiguous with the value "html" that gets imported indomonic/__init__.py
. I think the star import there is responsible but I'm no expert. Given that import, all of html's exports are accessible by dom; i.e. you can writedom.span("html")
which would seem to accomplish my needs but I don't think was intended in the design of these modules; that is I can confusingly writeimport domonic as html
when I wantimport domonic.html
.