Skip to content

NbBlock as a container #117

Open
Open
@pietroppeter

Description

@pietroppeter

currently you cannot nest block inside one another e.g. you cannot do stuff like:

nbCode:
   nbRawOutput: "<div>"
   echo "hello"
   nbRawOutput: "</div>

the above is not a great use case, a better use case would be to create html tabs:

nbTabs:
  tab("example 1"):
    nbText: "my example 1"
    nbCode: discard
  tab("example 2"):
    nbText: "my example 2"
    nbCode: discard
  tab("example 3"):
    nbText: "my example 3"
    nbCode: discard

and also nimislides has a similar use case when it does:

slide:
  slide:
    ...
  slide:
    ...

as a first thought there should be 3 changes to make:

  • change block making it a variant type based on a isContainer field. If it is container you have fields blocks: seq[NbBlock], blk: NbBlock as in NbDoc
  • need also to change nb object to track who is current container, either nb itself or some container block (so that the newNbBlock template can be called with correct container where to add the block)
  • finally we will need to change rendering, which should be straightforward

it is possible that this does not break too much the api, so it could be considered for 0.3.x

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions