import “common”

mixin iterate_toc(toc_item)

- if toc_item.sub_items.count > 0
        ul.spine
                - toc_item.sub_items.each do |item|
                        - unless item.title.nil?
                                li
                                        - item_href = "/book/#{pretty_path_toc_item(item)}"
                                        - unless item.title.nil?
                                                span.title: a.title(href: item_href)= item.title
                                        - end
                                        - unless item.options.empty?
                        = ' '
                - end
                                        - item.options.each do |opt|
                                                - next if opt.nil?
                                                = ' '
                                                span.option= opt.inspect
                                        - end
                                        +iterate_toc(item)
                        - end
                - end
- end

+page(title: ‘TOC’, header_id: ‘toc’)

#content.toc_content
        +iterate_toc(target.root_toc)