diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-05-21 17:47:52 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-05-21 18:52:13 +0200 |
commit | 2f17f9378ad96c4a9f6d7d24b0776ed3a25a08a3 (patch) | |
tree | 5b7885e08af3628869cbe93088923b29e81ce6a3 /hugolib/shortcode_test.go | |
parent | 0a7027e2a87283743d5310b74e18666e4a64d3e1 (diff) |
Do not return error on .Get "class" and vice versa in shortcodes
The current error handling makes parameter checking in shortcodes too verbose for no good reason.
Fixes #4745
Diffstat (limited to 'hugolib/shortcode_test.go')
-rw-r--r-- | hugolib/shortcode_test.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index a32487477..a4c6ca20d 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -185,17 +185,14 @@ func TestNestedNamedMissingParam(t *testing.T) { func TestIsNamedParamsSC(t *testing.T) { t.Parallel() wt := func(tem tpl.TemplateHandler) error { - tem.AddTemplate("_internal/shortcodes/byposition.html", `<div id="{{ .Get 0 }}">`) - tem.AddTemplate("_internal/shortcodes/byname.html", `<div id="{{ .Get "id" }}">`) + tem.AddTemplate("_internal/shortcodes/bynameorposition.html", `{{ with .Get "id" }}Named: {{ . }}{{ else }}Pos: {{ .Get 0 }}{{ end }}`) tem.AddTemplate("_internal/shortcodes/ifnamedparams.html", `<div id="{{ if .IsNamedParams }}{{ .Get "id" }}{{ else }}{{ .Get 0 }}{{end}}">`) return nil } CheckShortCodeMatch(t, `{{< ifnamedparams id="name" >}}`, `<div id="name">`, wt) CheckShortCodeMatch(t, `{{< ifnamedparams position >}}`, `<div id="position">`, wt) - CheckShortCodeMatch(t, `{{< byname id="name" >}}`, `<div id="name">`, wt) - CheckShortCodeMatch(t, `{{< byname position >}}`, `<div id="error: cannot access positional params by string name">`, wt) - CheckShortCodeMatch(t, `{{< byposition position >}}`, `<div id="position">`, wt) - CheckShortCodeMatch(t, `{{< byposition id="name" >}}`, `<div id="error: cannot access named params by position">`, wt) + CheckShortCodeMatch(t, `{{< bynameorposition id="name" >}}`, `Named: name`, wt) + CheckShortCodeMatch(t, `{{< bynameorposition position >}}`, `Pos: position`, wt) } func TestInnerSC(t *testing.T) { |