Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jpescador/hugo-future-imperfect.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio Pescador <jpescador@users.noreply.github.com>2016-03-15 07:29:13 +0300
committerJulio Pescador <jpescador@users.noreply.github.com>2016-03-15 07:29:13 +0300
commitfd8548e5f7395748c664d29638787051d0d7dbe5 (patch)
tree40de75c220177253cb46fa49cfa01fc752d8c814
parent588edf04f946904c2393c32fe54082a5c8748b12 (diff)
Reversing position 2 and 3 on shortcodev0.2
Position 2 will now be the alt value. Positions 3 will be the type value.
-rw-r--r--layouts/shortcodes/img-post.html48
1 files changed, 25 insertions, 23 deletions
diff --git a/layouts/shortcodes/img-post.html b/layouts/shortcodes/img-post.html
index 204a5ee..e67aaff 100644
--- a/layouts/shortcodes/img-post.html
+++ b/layouts/shortcodes/img-post.html
@@ -1,44 +1,46 @@
-<!-- params 2-3
- Can be positional or named
+<!--
+ params 2-4
+ Can be positional or named
- position 0, name: path
+ position 0, name: path
Can pass in the following values:
title: will use /img/LinkTitle as the path
date: will use /img/Year/Month as the path
/path/to/img: can pass in explicit path to the image
- position 1, name: file
+ position 1, name: file
Name of the file including the file extension
- position 2, name: type
+ position 2, name: alt
+ Name of the alternate text for the image
+
+ position 3, name: type
Can pass in the following values:
- post: places the image centered
+ center: places the image centered
left: places the image to the left
right: places the image to the right
-
- position 3, name: alt
- Name of the alternate text for the image
-->
{{ $numOfParams := len .Params }}
{{ if and (ge $numOfParams 2) (le $numOfParams 4) }}
<!-- Check if the Parameter is positional or named
- which can handle both. If the third parameter is
- not set then the default value will be post -->
+ which can handle both. -->
{{ if .IsNamedParams }}
{{ $.Scratch.Set "path" (.Get "path") }}
{{ $.Scratch.Set "file" (.Get "file") }}
- {{ $.Scratch.Set "type" (.Get "type") }}
{{ $.Scratch.Set "alt" (.Get "alt") }}
+ {{ $.Scratch.Set "type" (.Get "type") }}
{{ else }}
- {{ if ge $numOfParams 2 }}
- {{ $.Scratch.Set "path" (.Get 0) }}
- {{ $.Scratch.Set "file" (.Get 1) }}
- {{ if ge $numOfParams 3 }}
- {{ $.Scratch.Set "type" (.Get 2) }}
- {{ end }}
- {{ if ge $numOfParams 4 }}
- {{ $.Scratch.Set "alt" (.Get 3) }}
- {{ end }}
+ {{ $.Scratch.Set "path" (.Get 0) }}
+ {{ $.Scratch.Set "file" (.Get 1) }}
+ {{ if ge $numOfParams 3 }}
+ {{ $.Scratch.Set "alt" (.Get 2) }}
+ {{ else }}
+ {{ $.Scratch.Set "alt" "" }}
+ {{ end }}
+ {{ if ge $numOfParams 4 }}
+ {{ $.Scratch.Set "type" (.Get 3) }}
+ {{ else }}
+ {{ $.Scratch.Set "type" "center" }}
{{ end }}
{{ end }}
@@ -59,8 +61,8 @@
<img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" />
</span>
{{ else }}
- <span class="image center-image">
+ <p><span class="image center-image">
<img src="{{ $path }}/{{ $file }}" alt="{{ $alt }}" />
- </span>
+ </span></p>
{{ end }}
{{ end }}