Do not panic on index out of range in shortcode.Get

Fixes #1335
This commit is contained in:
Bjørn Erik Pedersen 2015-08-07 19:21:26 +02:00
parent 2805a6f80e
commit 35bb72c83e
2 changed files with 13 additions and 1 deletions

View file

@ -85,6 +85,12 @@ func TestPositionalParamSC(t *testing.T) {
CheckShortCodeMatch(t, "{{< video 47238zzb >}}", "Playing Video 47238zzb", tem)
}
func TestPositionalParamIndexOutOfBounds(t *testing.T) {
tem := tpl.New()
tem.AddInternalShortcode("video.html", `Playing Video {{ .Get 1 }}`)
CheckShortCodeMatch(t, "{{< video 47238zzb >}}", "Playing Video error: index out of range for positional param at position 1", tem)
}
func TestNamedParamSC(t *testing.T) {
tem := tpl.New()
tem.AddInternalShortcode("img.html", `<img{{ with .Get "src" }} src="{{.}}"{{end}}{{with .Get "class"}} class="{{.}}"{{end}}>`)