summaryrefslogtreecommitdiff
path: root/templates/page.mako
blob: 9e1f20f9536af2ed4d80fb8337c129cd2f728e0b (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
<%!
    title = ""
    uses_toc = False
%>

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

<h1 class="title">${self.attr.title}</h1>
${next.body()}

% if self.attr.uses_toc:
    <script type="text/javascript">
        createToc(${h.toJS(self.attr.tlist)})
    </script>
% endif


<%def name="style()">
    ${parent.style()}
    % if self.attr.uses_toc:
        <script src=${"/static/js/toc.js" | url} type="text/javascript"></script>
    % endif
</%def>

<%def name="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 = "#"
    %>
    <h2><a name="${name}"><span class="hstart">» </span></a>${caller.body()}</h2>
</%def>

<%def name="toc()">
    <div id="toc"></div>
</%def>