ref: 266511b6d392078695d0e22320f79fd4befe2f7a
parent: cafd39eb9bc8736c8c4fe24a905a3e9aba0b2272
author: bep <[email protected]>
date: Thu Oct 30 12:37:00 EDT 2014
Fix missing space before 'width' The newly introduced width-param on figure did not work in combo with alt or caption due to space-issues. This fixes that.
--- a/hugolib/shortcode_test.go
+++ b/hugolib/shortcode_test.go
@@ -72,13 +72,13 @@
func TestEmbeddedSC(t *testing.T) {
tem := NewTemplate()
CheckShortCodeMatch(t, "{{% test %}}", "This is a simple Test", tem)
- CheckShortCodeMatch(t, `{{% figure src="/found/here" class="bananas orange" %}}`, "\n<figure class=\"bananas orange\">\n \n <img src=\"/found/here\" />\n \n \n</figure>\n", tem)
+ CheckShortCodeMatch(t, `{{% figure src="/found/here" class="bananas orange" %}}`, "\n<figure class=\"bananas orange\">\n \n <img src=\"/found/here\" />\n \n \n</figure>\n", tem)
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)
+ CheckShortCodeMatch(t, `{{% figure src="/found/here" class="bananas orange" alt="apple" width="100px" %}}`, "\n<figure class=\"bananas orange\">\n \n <img src=\"/found/here\" alt=\"apple\" width=\"100px\" />\n \n \n</figure>\n", tem)
}
func TestUnbalancedQuotes(t *testing.T) {
--- a/hugolib/template_embedded.go
+++ b/hugolib/template_embedded.go
@@ -24,7 +24,7 @@
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 }}{{ with .Get "width" }}width="{{.}}"{{ 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" }}