Multiple-page structure with navigation

It’s easy to navigate between several files in different paths, using sub() method of NavedYawrap instance. Each call of sub() returns instance of given NavedYawrap class, with same styles and scripts as the parent one. Each page will be rendered with navigation section, with relative paths. See the hrefs in the example below.

The first document (home in this example) will be the root of the document structure.

def test_naved_yawrap():

    from exampling_tools import get_output_file_path
    from yawrap import NavedYawrap, EmbedCss

    class MyPage(NavedYawrap):
        resources = [EmbedCss("""\
        body {
            margin: 16;
            font-family: Verdana, sans-serif;
        }""")
                     ]

    out_file_1 = get_output_file_path("nav01a.html")
    home = MyPage(out_file_1, title="Title Force One")

    # fill content of root document
    with home.tag('p'):
        home.text("I'm home")

    # create a sub-document
    out_file_2 = get_output_file_path(os.path.join("some", "deep", "nonexistent", "path", "nav01b.html"))
    about = home.sub(out_file_2, 'Abouting')

    with about.tag('div'):
        about.text('Always do the abouting!')

    home.render_all_files()

    # at this point files are generated

Generates two html pages:

Notice, how the href is calculated.

Here’s the page: