Skip to content

Rearrange (and add) nodes in the body of a document. #171

Answered by Knio
alper-t asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you can do this manually by manipulating the children attribute (it's just a list), ie:

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")

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alper-t
Comment options

Answer selected by alper-t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants