gobyexample/templates/example.tmpl
Mark McGranaghan 78e1fd61ec Clean up merge
2019-09-01 16:09:36 -07:00

56 lines
1.8 KiB
Cheetah

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Go by Example: {{.Name}}</title>
<link rel=stylesheet href="site.css">
</head>
<script>
onkeydown = (e) => {
{{if .PrevExample}}
if (e.key == "ArrowLeft") {
window.location.href = '{{.PrevExample.ID}}';
}
{{end}}
{{if .NextExample}}
if (e.key == "ArrowRight") {
window.location.href = '{{.NextExample.ID}}';
}
{{end}}
}
</script>
<body>
<div class="example" id="{{.ID}}">
<h2><a href="./">Go by Example</a>: {{.Name}}</h2>
{{range .Segs}}
<table>
{{range .}}
<tr>
<td class="docs">
{{.DocsRendered}}
</td>
<td class="code{{if .CodeEmpty}} empty{{end}}{{if .CodeLeading}} leading{{end}}">
{{if .CodeRun}}<a href="http://play.golang.org/p/{{$.URLHash}}"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />{{end}}
{{.CodeRendered}}
</td>
</tr>
{{end}}
</table>
{{end}}
{{if .NextExample}}
<p class="next">
Next example: <a href="{{.NextExample.ID}}">{{.NextExample.Name}}</a>.
</p>
{{end}}
<p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> | <a href="https://github.com/mmcgrana/gobyexample/blob/master/examples/{{.ID}}">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a>
</p>
</div>
<script>
var codeLines = [];
{{range .Segs}}{{range .}}codeLines.push('{{js .CodeForJs}}');{{end}}{{end}}
</script>
<script src="site.js" async></script>
</body>
</html>