add 'width' parameter to 'figure' shortcode - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 3da97656ea4c32fe7619945df7a13bc73cdca3fd
DIR parent fb82f00f9d0341a976241c9c062304adb43b3794
HTML Author: Raphael Estrada <galaktor@gmx.de>
Date: Wed, 8 Oct 2014 15:54:50 +0100
add 'width' parameter to 'figure' shortcode
Diffstat:
M hugolib/shortcode_test.go | 5 +++++
M hugolib/template_embedded.go | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
---
DIR diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go
@@ -76,6 +76,11 @@ func TestEmbeddedSC(t *testing.T) {
CheckShortCodeMatch(t, `{{% figure src="/found/here" class="bananas orange" caption="This is a caption" %}}`, "\n<figure class=\"bananas orange\">\n \n <img src=\"/found/here\" alt=\"This is a caption\" />\n \n \n <figcaption>\n <p>\n This is a caption\n \n \n \n </p> \n </figcaption>\n \n</figure>\n", tem)
}
+func TestFigureImgWidth(t *testing.T) {
+ tem := NewTemplate()
+ CheckShortCodeMatch(t, `{{% figure src="/found/here" class="bananas orange" width="100px" %}}`, "\n<figure class=\"bananas orange\">\n \n <img src=\"/found/here\" width=\"100px\" />\n \n \n</figure>\n", tem)
+}
+
func TestUnbalancedQuotes(t *testing.T) {
tem := NewTemplate()
DIR diff --git a/hugolib/template_embedded.go b/hugolib/template_embedded.go
@@ -24,7 +24,7 @@ func (t *GoHtmlTemplate) EmbedShortcodes() {
t.AddInternalShortcode("figure.html", `<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
- <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
+ <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }}{{ with .Get "width" }}width="{{.}}"{{ end }} />
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}