mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 04:16:13 +00:00
add .html suffix to partial usage and references
This commit is contained in:
1 parent
3213e00f25
commit
29180e4d2a
4 files changed
+12
-12
No files matched your search
@@ -64,13 +64,13 @@ If you have `post-tag-list.html` and `post-tag-link.html` as [partials][], you *
|
|||||||
Tags:
|
Tags:
|
||||||
{{ $len := len . }}
|
{{ $len := len . }}
|
||||||
{{ if eq $len 1 }}
|
{{ if eq $len 1 }}
|
||||||
{{ partial "post-tag-link" (index . 0) }}
|
{{ partial "post-tag-link.html" (index . 0) }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $last := sub $len 1 }}
|
{{ $last := sub $len 1 }}
|
||||||
{{ range first $last . }}
|
{{ range first $last . }}
|
||||||
{{ partial "post-tag-link" . }},
|
{{ partial "post-tag-link.html" . }},
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ partial "post-tag-link" (index . $last) }}
|
{{ partial "post-tag-link.html" (index . $last) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@@ -89,7 +89,7 @@ This first version of `layouts/partials/post-tag-list.html` separates all of the
|
|||||||
<div class="tags-list">
|
<div class="tags-list">
|
||||||
Tags:
|
Tags:
|
||||||
{{ $sort := sort . }}
|
{{ $sort := sort . }}
|
||||||
{{ $links := apply $sort "partial" "post-tag-link" "." }}
|
{{ $links := apply $sort "partial" "post-tag-link.html" "." }}
|
||||||
{{ $clean := apply $links "chomp" "." }}
|
{{ $clean := apply $links "chomp" "." }}
|
||||||
{{ delimit $clean ", " }}
|
{{ delimit $clean ", " }}
|
||||||
</div>
|
</div>
|
||||||
@@ -102,7 +102,7 @@ Now in the completed version, you can sort the tags, convert the tags to links w
|
|||||||
{{ with .Params.tags }}
|
{{ with .Params.tags }}
|
||||||
<div class="tags-list">
|
<div class="tags-list">
|
||||||
Tags:
|
Tags:
|
||||||
{{ delimit (apply (apply (sort .) "partial" "post-tag-link" ".") "chomp" ".") ", " }}
|
{{ delimit (apply (apply (sort .) "partial" "post-tag-link.html" ".") "chomp" ".") ", " }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{< /code >}}
|
{{< /code >}}
|
||||||
|
|||||||
@@ -126,9 +126,9 @@ Only one `return` statement is allowed per partial file.
|
|||||||
You can also define partials inline in the template. But remember that template namespace is global, so you need to make sure that the names are unique to avoid conflicts.
|
You can also define partials inline in the template. But remember that template namespace is global, so you need to make sure that the names are unique to avoid conflicts.
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
Value: {{ partial "my-inline-partial" . }}
|
Value: {{ partial "my-inline-partial.html" . }}
|
||||||
|
|
||||||
{{ define "partials/my-inline-partial" }}
|
{{ define "partials/my-inline-partial.html" }}
|
||||||
{{ $value := 32 }}
|
{{ $value := 32 }}
|
||||||
{{ return $value }}
|
{{ return $value }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ When developing a [homepage][], what does one of the pages you're looping throug
|
|||||||
Check that you are passing variables in the `partial` function:
|
Check that you are passing variables in the `partial` function:
|
||||||
|
|
||||||
```
|
```
|
||||||
{{ partial "header" }}
|
{{ partial "header.html" }}
|
||||||
```
|
```
|
||||||
|
|
||||||
This example will render the header partial, but the header partial will not have access to any contextual variables. You need to pass variables explicitly. For example, note the addition of ["the dot"][tempintro].
|
This example will render the header partial, but the header partial will not have access to any contextual variables. You need to pass variables explicitly. For example, note the addition of ["the dot"][tempintro].
|
||||||
|
|
||||||
```
|
```
|
||||||
{{ partial "header" . }}
|
{{ partial "header.html" . }}
|
||||||
```
|
```
|
||||||
|
|
||||||
The dot (`.`) is considered fundamental to understanding Hugo templating. For more information, see [Introduction to Hugo Templating][tempintro].
|
The dot (`.`) is considered fundamental to understanding Hugo templating. For more information, see [Introduction to Hugo Templating][tempintro].
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
{{ $recent := ($byLastMod | last 30).Reverse }}
|
{{ $recent := ($byLastMod | last 30).Reverse }}
|
||||||
{{ $leastRecent := $byLastMod | first 10 }}
|
{{ $leastRecent := $byLastMod | first 10 }}
|
||||||
<h2 id="last-updated">Last Updated</h2>
|
<h2 id="last-updated">Last Updated</h2>
|
||||||
{{ partial "maintenance-pages-table" $recent }}
|
{{ partial "maintenance-pages-table.html" $recent }}
|
||||||
<h2 id="least-recently-updated">Least Recently Updated</h2>
|
<h2 id="least-recently-updated">Least Recently Updated</h2>
|
||||||
{{ partial "maintenance-pages-table" $leastRecent }}
|
{{ partial "maintenance-pages-table.html" $leastRecent }}
|
||||||
|
|
||||||
{{/* Don't think this is possible with where directly. Should investigate. */}}
|
{{/* Don't think this is possible with where directly. Should investigate. */}}
|
||||||
{{ .Scratch.Set "todos" slice }}
|
{{ .Scratch.Set "todos" slice }}
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<h2 id="todos">Pages marked with TODO</h2>
|
<h2 id="todos">Pages marked with TODO</h2>
|
||||||
{{ partial "maintenance-pages-table" (.Scratch.Get "todos") }}
|
{{ partial "maintenance-pages-table.html" (.Scratch.Get "todos") }}
|
||||||
|
|
||||||
<h2 id="dependencies">Dependencies</h2>
|
<h2 id="dependencies">Dependencies</h2>
|
||||||
<table class="collapse ba br2 b--black-10 pv2 ph3">
|
<table class="collapse ba br2 b--black-10 pv2 ph3">
|
||||||
|
|||||||
Reference in new issue
Block a user