add 'width' parameter to 'figure' shortcode
authorRaphael Estrada <galaktor@gmx.de>
Wed, 8 Oct 2014 14:54:50 +0000 (15:54 +0100)
committerspf13 <steve.francia@gmail.com>
Wed, 15 Oct 2014 16:09:26 +0000 (12:09 -0400)
hugolib/shortcode_test.go
hugolib/template_embedded.go

index 115c70fddbd941ab5f08ddc72267e4768c4706be..5ec793250b0ef8befff19de47c1bce1c5b7d5699 100644 (file)
@@ -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()
 
index 6a1dbd91f7fba670f3349d58f14a50970336816f..5dec5e6bf896cf32b499e9a36fa6aa3dfc44d847 100644 (file)
@@ -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" }}