1
0
mirror of https://github.com/golang/go synced 2024-11-25 07:37:57 -07:00

godoc: template cleanup

Use naming convention for template variables
to indicate "escaped-ness" for easier reviewing.
(per suggestion from bradfitz)

R=bradfitz
CC=golang-dev
https://golang.org/cl/4914041
This commit is contained in:
Robert Griesemer 2011-08-17 16:38:58 -07:00
parent 75cb084283
commit 0f801ff81e
5 changed files with 28 additions and 28 deletions

View File

@ -7,8 +7,8 @@
<table class="layout"> <table class="layout">
{{range .}} {{range .}}
<tr> <tr>
{{$name := html .Name}} {{$name_html := html .Name}}
<td><a href="{{$name}}">{{$name}}</a></td> <td><a href="{{$name_html}}">{{$name_html}}</a></td>
<td width="25">&nbsp;</td> <td width="25">&nbsp;</td>
<td>{{html .Title}}</td> <td>{{html .Title}}</td>
</tr> </tr>

View File

@ -18,12 +18,12 @@
</tr> </tr>
{{range .}} {{range .}}
<tr> <tr>
{{$name := .|fileInfoName|html}} {{$name_html := fileInfoName . | html}}
<td align="left"><a href="{{$name}}">{{$name}}</a></td> <td align="left"><a href="{{$name_html}}">{{$name_html}}</a></td>
<td></td> <td></td>
<td align="right">{{html .Size}}</td> <td align="right">{{html .Size}}</td>
<td></td> <td></td>
<td align="left">{{.|fileInfoTime|html}}</td> <td align="left">{{fileInfoTime . | html}}</td>
</tr> </tr>
{{end}} {{end}}

View File

@ -41,16 +41,16 @@
{{with .Funcs}} {{with .Funcs}}
{{range .}} {{range .}}
{{/* Name is a string - no need for FSet */}} {{/* Name is a string - no need for FSet */}}
{{$name := html .Name}} {{$name_html := html .Name}}
<h2 id="{{$name}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name}}</a></h2> <h2 id="{{$name_html}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h2>
<p><code>{{node_html .Decl $.FSet}}</code></p> <p><code>{{node_html .Decl $.FSet}}</code></p>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}
{{end}} {{end}}
{{with .Types}} {{with .Types}}
{{range .}} {{range .}}
{{$tname := node_html .Type.Name $.FSet}} {{$tname_html := node_html .Type.Name $.FSet}}
<h2 id="{{$tname}}">type <a href="/{{posLink_url .Decl $.FSet}}">{{$tname}}</a></h2> <h2 id="{{$tname_html}}">type <a href="/{{posLink_url .Decl $.FSet}}">{{$tname_html}}</a></h2>
{{comment_html .Doc}} {{comment_html .Doc}}
<p><pre>{{node_html .Decl $.FSet}}</pre></p> <p><pre>{{node_html .Decl $.FSet}}</pre></p>
{{range .Consts}} {{range .Consts}}
@ -62,14 +62,14 @@
<pre>{{node_html .Decl $.FSet}}</pre> <pre>{{node_html .Decl $.FSet}}</pre>
{{end}} {{end}}
{{range .Factories}} {{range .Factories}}
{{$name := html .Name}} {{$name_html := html .Name}}
<h3 id="{{$tname}}.{{$name}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name}}</a></h3> <h3 id="{{$tname_html}}.{{$name_html}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
<p><code>{{node_html .Decl $.FSet}}</code></p> <p><code>{{node_html .Decl $.FSet}}</code></p>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}
{{range .Methods}} {{range .Methods}}
{{$name := html .Name}} {{$name_html := html .Name}}
<h3 id="{{$tname}}.{{$name}}">func ({{node_html .Recv $.FSet}}) <a href="/{{posLink_url .Decl $.FSet}}">{{$name}}</a></h3> <h3 id="{{$tname_html}}.{{$name_html}}">func ({{node_html .Recv $.FSet}}) <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
<p><code>{{node_html .Decl $.FSet}}</code></p> <p><code>{{node_html .Decl $.FSet}}</code></p>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}

View File

@ -3,7 +3,7 @@
Use of this source code is governed by a BSD-style Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. license that can be found in the LICENSE file.
--> -->
{{$query := urlquery .Query}} {{$query_url := urlquery .Query}}
{{with .Alert}} {{with .Alert}}
<p> <p>
<span class="alert" style="font-size:120%">{{html .}}</span> <span class="alert" style="font-size:120%">{{html .}}</span>
@ -21,13 +21,13 @@
{{with .Decls}} {{with .Decls}}
<h2 id="Global">Package-level declarations</h2> <h2 id="Global">Package-level declarations</h2>
{{range .}} {{range .}}
{{$pkg := pkgLink .Pak.Path | html}} {{$pkg_html := pkgLink .Pak.Path | html}}
<h3 id="Global_{{$pkg}}">package <a href="/{{$pkg}}">{{html .Pak.Name}}</a></h3> <h3 id="Global_{{$pkg_html}}">package <a href="/{{$pkg_html}}">{{html .Pak.Name}}</a></h3>
{{range .Files}} {{range .Files}}
{{$src := srcLink .File.Path | html}} {{$src_html := srcLink .File.Path | html}}
{{range .Groups}} {{range .Groups}}
{{range .Infos}} {{range .Infos}}
<a href="/{{$src}}?h={{$query}}#L{{infoLine .}}">{{$src}}:{{infoLine .}}</a> <a href="/{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{$src_html}}:{{infoLine .}}</a>
{{infoSnippet_html .}} {{infoSnippet_html .}}
{{end}} {{end}}
{{end}} {{end}}
@ -37,11 +37,11 @@
{{with .Others}} {{with .Others}}
<h2 id="Local">Local declarations and uses</h2> <h2 id="Local">Local declarations and uses</h2>
{{range .}} {{range .}}
{{$pkg := pkgLink .Pak.Path | html}} {{$pkg_html := pkgLink .Pak.Path | html}}
<h3 id="Local_{{$pkg}}">package <a href="/{{$pkg}}">{{html .Pak.Name}}</a></h3> <h3 id="Local_{{$pkg_html}}">package <a href="/{{$pkg_html}}">{{html .Pak.Name}}</a></h3>
{{range .Files}} {{range .Files}}
{{$src := srcLink .File.Path | html}} {{$src_html := srcLink .File.Path | html}}
<a href="/{{$src}}?h={{$query}}">{{$src}}</a> <a href="/{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>
<table class="layout"> <table class="layout">
{{range .Groups}} {{range .Groups}}
<tr> <tr>
@ -50,7 +50,7 @@
<td align="left" width="4"></td> <td align="left" width="4"></td>
<td> <td>
{{range .Infos}} {{range .Infos}}
<a href="/{{$src}}?h={{$query}}#L{{infoLine .}}">{{infoLine .}}</a> <a href="/{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{infoLine .}}</a>
{{end}} {{end}}
</td> </td>
</tr> </tr>
@ -72,17 +72,17 @@
<p> <p>
<table class="layout"> <table class="layout">
{{range .}} {{range .}}
{{$src := srcLink .Filename | html}} {{$src_html := srcLink .Filename | html}}
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<a href="/{{$src}}?h={{$query}}">{{$src}}</a>: <a href="/{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>:
</td> </td>
<td align="left" width="4"></td> <td align="left" width="4"></td>
<th align="left" valign="top">{{len .Lines}}</th> <th align="left" valign="top">{{len .Lines}}</th>
<td align="left" width="4"></td> <td align="left" width="4"></td>
<td align="left"> <td align="left">
{{range .Lines}} {{range .Lines}}
<a href="/{{$src}}?h={{$query}}#L{{html .}}">{{html .}}</a> <a href="/{{$src_html}}?h={{$query_url}}#L{{html .}}">{{html .}}</a>
{{end}} {{end}}
{{if not $.Complete}} {{if not $.Complete}}
... ...

View File

@ -17,7 +17,7 @@ DID YOU MEAN
PACKAGE-LEVEL DECLARATIONS PACKAGE-LEVEL DECLARATIONS
{{range .}}package {{.Pak.Name}} {{range .}}package {{.Pak.Name}}
{{range $File := .Files}}{{range .Groups}}{{range .Infos}} {{srcLink $File.File.Path}}:{{infoLine .}}{{end}} {{range $file := .Files}}{{range .Groups}}{{range .Infos}} {{srcLink $file.File.Path}}:{{infoLine .}}{{end}}
{{end}}{{end}}{{/* .Files */}} {{end}}{{end}}{{/* .Files */}}
{{end}}{{end}}{{/* .Decls */}}{{/* {{end}}{{end}}{{/* .Decls */}}{{/*
@ -27,7 +27,7 @@ PACKAGE-LEVEL DECLARATIONS
LOCAL DECLARATIONS AND USES LOCAL DECLARATIONS AND USES
{{range .}}package {{.Pak.Name}} {{range .}}package {{.Pak.Name}}
{{range $File := .Files}}{{range .Groups}}{{range .Infos}} {{srcLink $File.File.Path}}:{{infoLine .}} {{range $file := .Files}}{{range .Groups}}{{range .Infos}} {{srcLink $file.File.Path}}:{{infoLine .}}
{{end}}{{end}}{{end}}{{/* .Files */}} {{end}}{{end}}{{end}}{{/* .Files */}}
{{end}}{{end}}{{/* .Others */}}{{end}}{{/* .Hit */}}{{/* {{end}}{{end}}{{/* .Others */}}{{end}}{{/* .Hit */}}{{/*