Templates complete
parent
f0da255c6a
commit
13445115da
@ -1,6 +1,23 @@
|
||||
{{define "title"}}Home{{end}}
|
||||
|
||||
{{define "main" -}}
|
||||
<h2>Latest Snippets</h2>
|
||||
<p>There's nothing to see yet!</p>
|
||||
{{ if .Snippets}}
|
||||
<table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Created</th>
|
||||
<th>ID</th>
|
||||
</tr>
|
||||
{{range .Snippets}}
|
||||
<tr>
|
||||
<td><a href='/snippet/view/{{.ID}}'>{{.Title.String}}</a></td>
|
||||
<!-- this is an example of pipelineing instead of function call -->
|
||||
<td>{{.CreatedAt | humanDate }}</td>
|
||||
<td>#{{.ID}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
{{else}}
|
||||
<p>There's nothing to see yet!</p>
|
||||
{{end}}
|
||||
{{- end -}}
|
||||
|
@ -1,17 +1,19 @@
|
||||
{{define "title"}}Snippet #{{.Snippet.ID}}{{end}}
|
||||
|
||||
{{define "main"}}
|
||||
{{ with .Snippet }}
|
||||
<!-- This is a comment that will be stripped out by html/template -->
|
||||
<div class="snippet">
|
||||
<div class="metadata">
|
||||
<strong>{{.Snippet.Title.String }}</strong>
|
||||
<span>#{{.Snippet.ID}}</span>
|
||||
<strong>{{.Title.String }}</strong>
|
||||
<span>#{{.ID}}</span>
|
||||
</div>
|
||||
<pre><code>{{.Snippet.Content.String }}</code></pre>
|
||||
<pre><code>{{.Content.String }}</code></pre>
|
||||
<div class="metadata">
|
||||
<time>Created: {{.Snippet.CreatedAt}}</time>
|
||||
<time>Expires: {{.Snippet.ExpiresAt}}</time>
|
||||
<time>Created: {{ humanDate .CreatedAt}}</time>
|
||||
<time>Expires: {{ humanDate .ExpiresAt}}</time>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{end}}
|
||||
|
Loading…
Reference in New Issue