package hugolib import ( "fmt" "reflect" "regexp" "sort" "strings" "testing" "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/tpl" "github.com/spf13/viper" ) func pageFromString(in, filename string) (*Page, error) { return NewPageFrom(strings.NewReader(in), filename) } func CheckShortCodeMatch(t *testing.T, input, expected string, template tpl.Template) { p, _ := pageFromString(SIMPLE_PAGE, "simple.md") output := ShortcodesHandle(input, p, template) if output != expected { t.Fatalf("Shortcode render didn't match. Expected: %q, Got: %q", expected, output) } } func TestNonSC(t *testing.T) { tem := tpl.New() // notice the syntax diff from 0.12, now comment delims must be added CheckShortCodeMatch(t, "{{%/* movie 47238zzb */%}}", "{{% movie 47238zzb %}}", tem) } // Issue #929 func TestHyphenatedSC(t *testing.T) { tem := tpl.New() tem.AddInternalShortcode("hyphenated-video.html", `Playing Video {{ .Get 0 }}`) CheckShortCodeMatch(t, "{{< hyphenated-video 47238zzb >}}", "Playing Video 47238zzb", tem) } func TestPositionalParamSC(t *testing.T) { tem := tpl.New() tem.AddInternalShortcode("video.html", `Playing Video {{ .Get 0 }}`) CheckShortCodeMatch(t, "{{< video 47238zzb >}}", "Playing Video 47238zzb", tem) CheckShortCodeMatch(t, "{{< video 47238zzb 132 >}}", "Playing Video 47238zzb", tem) CheckShortCodeMatch(t, "{{