-
Hi, This library looks very promising! I was wondering, is it possible to rearrange the order of the nodes (within the body tag)? Hopefully I can clarify my question by giving some (pseudo) code. def layout():
doc = dominate.document(title='Dominate your HTML')
with doc.head:
link(rel='stylesheet', href='style.css')
script(type='text/javascript', src='script.js')
with doc:
with div():
attr(cls='body')
p('Lorem ipsum..')
p('Hello World')
return doc # Get the document by calling the function and then trying to edit it.
doc = layout()
# Is it possible to get the document and then flip the around and add a tag above?
# e.g.
doc.body[0] = p("Add Text Here")
# Should result in.
p("Add Text Here")
p('Hello World')
p('Lorem ipsum..')
|
Beta Was this translation helpful? Give feedback.
Answered by
Knio
Apr 6, 2023
Replies: 1 comment 1 reply
-
Hi, you can do this manually by manipulating the doc = ...
do_stuff(doc) ...
doc.body.children.insert(0, div('this goes first')) I also sometimes use the pattern of a wrapper element, ie: with doc:
header = div() # empty
p("Lorem ipsum"}
...
with header:
p("this goes first") |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
alper-t
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, you can do this manually by manipulating the
children
attribute (it's just a list), ie:I also sometimes use the pattern of a wrapper element, ie: