summaryrefslogtreecommitdiff
path: root/templates/page.mako
blob: aa2aa51bafc3a1a16457501b387b0cc1db8eb04c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<%!
    title = ""
    uses_toc = False
%>
<%
    page_text = capture(next.body)
%>

<%inherit file="/root.mako" />

## content

<h1 class="title">${self.attr.title}</h1>
% if self.attr.uses_toc:
    ${self.preface()}
    ${self.toc()}
% endif

${page_text}

## functions

<%def name="h2(tag='h2')">
    <% 
        if self.attr.uses_toc:
            c = capture(caller.body)
            name = c.replace(" ", "_").replace("/", "_").lower()
            tlist = getattr(self.attr, "tlist", [])
            tlist.append((str(name), str(c)))

            self.attr.tlist = tlist
        else:
            name = "#"
    %>
    <${tag}><a name="${name}"><span class="hstart">» </span></a>${caller.body()}</${tag}>
</%def>

<%def name="toc()">
    <ul id="toc">
        % for url, name in self.attr.tlist:
            <li><a class="tocLink" href="#${url}">${name}</a></li>
        % endfor
    </ul>
</%def>

<%def name="preface()"></%def>