summaryrefslogtreecommitdiff
path: root/template/doc.tmpl
blob: 356410a29e46329b5409bd120236f44ef9a9aca8 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{{/* This doc template is given to the present tool to format articles.  */}}

{{define "root"}}
  {{with .Subtitle}}<h3>{{.}}</h3>{{end}}
  {{if .Doc | sectioned}}
    {{range .Sections}}
      {{elem $.Template .}}
    {{end}}
  {{else}}
    {{with index .Sections 0}}
      {{range .Elem}}
        {{elem $.Template .}}
      {{end}}
    {{end}}
  {{end}}
{{end}}

{{define "TOC"}}
  <ul>
  {{range .}}
    <li><a href="#TOC_{{.FormattedNumber}}">{{.Title}}</a></li>
    {{with .Sections}}{{template "TOC" .}}{{end}}
  {{end}}
  </ul>
{{end}}

{{define "newline"}}
{{/* newline */}}
{{end}}

{{define "section"}}
  <h4 id="TOC_{{.FormattedNumber}}">{{.Title}}</h4>
  {{range .Elem}}{{elem $.Template .}}{{end}}
{{end}}

{{define "list"}}
  <ul>
  {{range .Bullet}}
    <li>{{style .}}</li>
  {{end}}
  </ul>
{{end}}

{{define "text"}}
  {{if .Pre}}
  <pre>{{range .Lines}}{{.}}{{end}}</pre>
  {{else}}
  <p>
    {{range $i, $l := .Lines}}{{if $i}}{{template "newline"}}
    {{end}}{{style $l}}{{end}}
  </p>
  {{end}}
{{end}}

{{define "code"}}
  <div class="code">{{.Text}}</div>
{{end}}

{{define "image"}}
  <img src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}} alt="image">
{{end}}

{{define "caption"}}
  <figcaption>{{style .Text}}</figcaption>
{{end}}

{{define "iframe"}}
<div class="iframe">
  <iframe src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}} frameborder="0" allowfullscreen mozallowfullscreen webkitallowfullscreen></iframe>
</div>
{{end}}

{{define "link"}}
  <p class="link"><a href="{{.URL}}" target="_blank">{{style .Label}}</a></p>
{{end}}

{{define "html"}}{{.HTML}}{{end}}