|
1 | | -<!-- params 2-3 |
2 | | - Can be positional or named |
| 1 | +<!-- |
| 2 | + params 2-4 |
| 3 | + Can be positional or named |
3 | 4 |
|
4 | | - position 0, name: path |
| 5 | + position 0, name: path |
5 | 6 | Can pass in the following values: |
6 | 7 | title: will use /img/LinkTitle as the path |
7 | 8 | date: will use /img/Year/Month as the path |
8 | 9 | /path/to/img: can pass in explicit path to the image |
9 | 10 |
|
10 | | - position 1, name: file |
| 11 | + position 1, name: file |
11 | 12 | Name of the file including the file extension |
12 | 13 |
|
13 | | - position 2, name: type |
| 14 | + position 2, name: alt |
| 15 | + Name of the alternate text for the image |
| 16 | +
|
| 17 | + position 3, name: type |
14 | 18 | Can pass in the following values: |
15 | | - post: places the image centered |
| 19 | + center: places the image centered |
16 | 20 | left: places the image to the left |
17 | 21 | right: places the image to the right |
18 | | -
|
19 | | - position 3, name: alt |
20 | | - Name of the alternate text for the image |
21 | 22 | --> |
22 | 23 | {{ $numOfParams := len .Params }} |
23 | 24 | {{ if and (ge $numOfParams 2) (le $numOfParams 4) }} |
24 | 25 | <!-- Check if the Parameter is positional or named |
25 | | - which can handle both. If the third parameter is |
26 | | - not set then the default value will be post --> |
| 26 | + which can handle both. --> |
27 | 27 | {{ if .IsNamedParams }} |
28 | 28 | {{ $.Scratch.Set "path" (.Get "path") }} |
29 | 29 | {{ $.Scratch.Set "file" (.Get "file") }} |
30 | | - {{ $.Scratch.Set "type" (.Get "type") }} |
31 | 30 | {{ $.Scratch.Set "alt" (.Get "alt") }} |
| 31 | + {{ $.Scratch.Set "type" (.Get "type") }} |
32 | 32 | {{ else }} |
33 | | - {{ if ge $numOfParams 2 }} |
34 | | - {{ $.Scratch.Set "path" (.Get 0) }} |
35 | | - {{ $.Scratch.Set "file" (.Get 1) }} |
36 | | - {{ if ge $numOfParams 3 }} |
37 | | - {{ $.Scratch.Set "type" (.Get 2) }} |
38 | | - {{ end }} |
39 | | - {{ if ge $numOfParams 4 }} |
40 | | - {{ $.Scratch.Set "alt" (.Get 3) }} |
41 | | - {{ end }} |
| 33 | + {{ $.Scratch.Set "path" (.Get 0) }} |
| 34 | + {{ $.Scratch.Set "file" (.Get 1) }} |
| 35 | + {{ if ge $numOfParams 3 }} |
| 36 | + {{ $.Scratch.Set "alt" (.Get 2) }} |
| 37 | + {{ else }} |
| 38 | + {{ $.Scratch.Set "alt" "" }} |
| 39 | + {{ end }} |
| 40 | + {{ if ge $numOfParams 4 }} |
| 41 | + {{ $.Scratch.Set "type" (.Get 3) }} |
| 42 | + {{ else }} |
| 43 | + {{ $.Scratch.Set "type" "center" }} |
42 | 44 | {{ end }} |
43 | 45 | {{ end }} |
44 | 46 |
|
|
59 | 61 | <img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" /> |
60 | 62 | </span> |
61 | 63 | {{ else }} |
62 | | - <span class="image center-image"> |
| 64 | + <p><span class="image center-image"> |
63 | 65 | <img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" /> |
64 | | - </span> |
| 66 | + </span></p> |
65 | 67 | {{ end }} |
66 | 68 | {{ end }} |
0 commit comments