• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang tpl.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/spf13/hugo/tpl.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestShortcodeYoutube

func TestShortcodeYoutube(t *testing.T) {
	for i, this := range []struct {
		in, expected string
	}{
		{
			`{{< youtube w7Ft2ymGmfc >}}`,
			"(?s)^\n<div style=\".*?\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\" style=\".*?\" allowfullscreen frameborder=\"0\">.*?</iframe>.*?</div>\n$",
		},
		// set class
		{
			`{{< youtube w7Ft2ymGmfc video>}}`,
			"(?s)^\n<div class=\"video\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\" allowfullscreen frameborder=\"0\">.*?</iframe>.*?</div>\n$",
		},
		// set class and autoplay (using named params)
		{
			`{{< youtube id="w7Ft2ymGmfc" class="video" autoplay="true" >}}`,
			"(?s)^\n<div class=\"video\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\\?autoplay=1\".*?allowfullscreen frameborder=\"0\">.*?</iframe>.*?</div>$",
		},
	} {
		templ := tpl.New()
		p, _ := pageFromString(simplePage, "simple.md")
		output, err := HandleShortcodes(this.in, p, templ)

		matched, err := regexp.MatchString(this.expected, output)

		if err != nil {
			t.Fatalf("[%d] Regexp error", i)
		}

		if !matched {
			t.Errorf("[%d] unexpected rendering, got %s\n", i, output)
		}
	}
}
开发者ID:tarsisazevedo,项目名称:hugo,代码行数:34,代码来源:embedded_shortcodes_test.go


示例2: TestHighlight

func TestHighlight(t *testing.T) {
	viper.Reset()
	defer viper.Reset()

	if !helpers.HasPygments() {
		t.Skip("Skip test as Pygments is not installed")
	}
	viper.Set("PygmentsStyle", "bw")
	viper.Set("PygmentsUseClasses", false)

	templ := tpl.New()

	code := `
{{< highlight java >}}
void do();
{{< /highlight >}}`

	p, _ := pageFromString(simplePage, "simple.md")
	output, err := HandleShortcodes(code, p, templ)

	if err != nil {
		t.Fatal("Handle shortcode error", err)
	}
	matched, err := regexp.MatchString("(?s)^\n<div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\">.*?void</span> do().*?</pre></div>\n$", output)

	if err != nil {
		t.Fatal("Regexp error", err)
	}

	if !matched {
		t.Error("Hightlight mismatch, got\n", output)
	}
}
开发者ID:xinzhi,项目名称:hugo,代码行数:33,代码来源:shortcode_test.go


示例3: TestShortcodeGoFuzzReports

func TestShortcodeGoFuzzReports(t *testing.T) {
	tem := tpl.New()

	tem.AddInternalShortcode("sc.html", `foo`)
	p, _ := pageFromString(SIMPLE_PAGE, "simple.md")

	for i, this := range []struct {
		data      string
		expectErr bool
	}{
		{"{{</*/", true},
	} {
		output, err := HandleShortcodes(this.data, p, tem)

		if this.expectErr && err == nil {
			t.Errorf("[%d] should have errored", i)
		}

		if !this.expectErr && err != nil {
			t.Errorf("[%d] should not have errored: %s", i, err)
		}

		if !this.expectErr && err == nil && len(output) == 0 {
			t.Errorf("[%d] empty result", i)
		}
	}

}
开发者ID:highPriestLOL,项目名称:hugo,代码行数:28,代码来源:shortcode_test.go


示例4: TestShortcodeVimeo

func TestShortcodeVimeo(t *testing.T) {
	for i, this := range []struct {
		in, expected string
	}{
		{
			`{{< vimeo 146022717 >}}`,
			"(?s)^\n<div style=\".*?\">.*?<iframe src=\"//player.vimeo.com/video/146022717\" style=\".*?\" webkitallowfullscreen mozallowfullscreen allowfullscreen>.*?</iframe>.*?</div>\n$",
		},
		// set class
		{
			`{{< vimeo 146022717 video >}}`,
			"(?s)^\n<div class=\"video\">.*?<iframe src=\"//player.vimeo.com/video/146022717\" webkitallowfullscreen mozallowfullscreen allowfullscreen>.*?</iframe>.*?</div>\n$",
		},
		// set class (using named params)
		{
			`{{< vimeo id="146022717" class="video" >}}`,
			"(?s)^<div class=\"video\">.*?<iframe src=\"//player.vimeo.com/video/146022717\" webkitallowfullscreen mozallowfullscreen allowfullscreen>.*?</iframe>.*?</div>$",
		},
	} {
		templ := tpl.New()
		p, _ := pageFromString(simplePage, "simple.md")
		output, err := HandleShortcodes(this.in, p, templ)

		matched, err := regexp.MatchString(this.expected, output)

		if err != nil {
			t.Fatalf("[%d] Regexp error", i)
		}

		if !matched {
			t.Errorf("[%d] unexpected rendering, got %s\n", i, output)
		}
	}
}
开发者ID:tarsisazevedo,项目名称:hugo,代码行数:34,代码来源:embedded_shortcodes_test.go


示例5: templatePrep

func templatePrep(s *Site) {
	s.Tmpl = tpl.New()
	s.Tmpl.LoadTemplates(s.absLayoutDir())
	if s.hasTheme() {
		s.Tmpl.LoadTemplatesWithPrefix(s.absThemeDir()+"/layouts", "theme")
	}
}
开发者ID:bramp,项目名称:hugo,代码行数:7,代码来源:site_test.go


示例6: doTestShortcodeCrossrefs

func doTestShortcodeCrossrefs(t *testing.T, relative bool) {
	var refShortcode string
	var expectedBase string

	if relative {
		refShortcode = "relref"
		expectedBase = "/bar"
	} else {
		refShortcode = "ref"
		expectedBase = baseURL
	}

	path := filepath.FromSlash("blog/post.md")
	in := fmt.Sprintf(`{{< %s "%s" >}}`, refShortcode, path)
	expected := fmt.Sprintf(`%s/simple/url/`, expectedBase)

	templ := tpl.New()
	p, _ := pageFromString(simplePageWithURL, path)
	p.Node.Site = &SiteInfo{
		Pages:   &(Pages{p}),
		BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(baseURL)),
	}

	output, err := HandleShortcodes(in, p, templ)

	if err != nil {
		t.Fatal("Handle shortcode error", err)
	}

	if output != expected {
		t.Errorf("Got\n%q\nExpected\n%q", output, expected)
	}
}
开发者ID:vincentsys,项目名称:hugo,代码行数:33,代码来源:embedded_shortcodes_test.go


示例7: TestShortcodeTweet

func TestShortcodeTweet(t *testing.T) {
	if testing.Short() {
		t.Skip("skipping Twitter test in short mode.")
	}

	for i, this := range []struct {
		in, expected string
	}{
		{
			`{{< tweet 666616452582129664 >}}`,
			"(?s)^<blockquote class=\"twitter-tweet\"><p lang=\"en\" dir=\"ltr\">Hugo 0.15 will have 30%\\+ faster render times thanks to this commit <a href=\"https://t.co/FfzhM8bNhT\">https://t.co/FfzhM8bNhT</a>  <a href=\"https://twitter.com/hashtag/gohugo\\?src=hash\">#gohugo</a> <a href=\"https://twitter.com/hashtag/golang\\?src=hash\">#golang</a> <a href=\"https://t.co/ITbMNU2BUf\">https://t.co/ITbMNU2BUf</a></p>&mdash; Steve Francia \\(@spf13\\) <a href=\"https://twitter.com/spf13/status/666616452582129664\">November 17, 2015</a></blockquote>.*?<script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>$",
		},
	} {
		templ := tpl.New()
		p, _ := pageFromString(simplePage, "simple.md")
		cacheFileID := viper.GetString("CacheDir") + url.QueryEscape("https://api.twitter.com/1/statuses/oembed.json?id=666616452582129664")
		defer os.Remove(cacheFileID)
		output, err := HandleShortcodes(this.in, p, templ)

		matched, err := regexp.MatchString(this.expected, output)

		if err != nil {
			t.Fatalf("[%d] Regexp error", i)
		}

		if !matched {
			t.Errorf("[%d] Hightlight mismatch, got %s\n", i, output)
		}
	}
}
开发者ID:vincentsys,项目名称:hugo,代码行数:30,代码来源:embedded_shortcodes_test.go


示例8: TestShortcodeGist

func TestShortcodeGist(t *testing.T) {
	for i, this := range []struct {
		in, expected string
	}{
		{
			`{{< gist spf13 7896402 >}}`,
			"(?s)^<script src=\"//gist.github.com/spf13/7896402.js\"></script>$",
		},
		{
			`{{< gist spf13 7896402 "img.html" >}}`,
			"(?s)^<script src=\"//gist.github.com/spf13/7896402.js\\?file=img.html\"></script>$",
		},
	} {
		templ := tpl.New()
		p, _ := pageFromString(simplePage, "simple.md")
		output, err := HandleShortcodes(this.in, p, templ)

		matched, err := regexp.MatchString(this.expected, output)

		if err != nil {
			t.Fatalf("[%d] Regexp error", i)
		}

		if !matched {
			t.Errorf("[%d] unexpected rendering, got %s\n", i, output)
		}
	}
}
开发者ID:tarsisazevedo,项目名称:hugo,代码行数:28,代码来源:embedded_shortcodes_test.go


示例9: TestInnerSC

func TestInnerSC(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("inside.html", `<div{{with .Get "class"}} class="{{.}}"{{end}}>{{ .Inner }}</div>`)

	CheckShortCodeMatch(t, `{{< inside class="aspen" >}}`, `<div class="aspen"></div>`, tem)
	CheckShortCodeMatch(t, `{{< inside class="aspen" >}}More Here{{< /inside >}}`, "<div class=\"aspen\">More Here</div>", tem)
	CheckShortCodeMatch(t, `{{< inside >}}More Here{{< /inside >}}`, "<div>More Here</div>", tem)
}
开发者ID:highPriestLOL,项目名称:hugo,代码行数:8,代码来源:shortcode_test.go


示例10: TestNestedSC

func TestNestedSC(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("scn1.html", `<div>Outer, inner is {{ .Inner }}</div>`)
	tem.AddInternalShortcode("scn2.html", `<div>SC2</div>`)

	CheckShortCodeMatch(t, `{{% scn1 %}}{{% scn2 %}}{{% /scn1 %}}`, "<div>Outer, inner is <div>SC2</div>\n</div>", tem)

	CheckShortCodeMatch(t, `{{< scn1 >}}{{% scn2 %}}{{< /scn1 >}}`, "<div>Outer, inner is <div>SC2</div></div>", tem)
}
开发者ID:highPriestLOL,项目名称:hugo,代码行数:9,代码来源:shortcode_test.go


示例11: TestParentShortcode

func TestParentShortcode(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("r1.html", `1: {{ .Get "pr1" }} {{ .Inner }}`)
	tem.AddInternalShortcode("r2.html", `2: {{ .Parent.Get "pr1" }}{{ .Get "pr2" }} {{ .Inner }}`)
	tem.AddInternalShortcode("r3.html", `3: {{ .Parent.Parent.Get "pr1" }}{{ .Parent.Get "pr2" }}{{ .Get "pr3" }} {{ .Inner }}`)

	CheckShortCodeMatch(t, `{{< r1 pr1="p1" >}}1: {{< r2 pr2="p2" >}}2: {{< r3 pr3="p3" >}}{{< /r3 >}}{{< /r2 >}}{{< /r1 >}}`,
		"1: p1 1: 2: p1p2 2: 3: p1p2p3 ", tem)

}
开发者ID:xinzhi,项目名称:hugo,代码行数:10,代码来源:shortcode_test.go


示例12: TestNestedNamedMissingParam

// Issue #2294
func TestNestedNamedMissingParam(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("acc.html", `<div class="acc">{{ .Inner }}</div>`)
	tem.AddInternalShortcode("div.html", `<div {{with .Get "class"}} class="{{ . }}"{{ end }}>{{ .Inner }}</div>`)
	tem.AddInternalShortcode("div2.html", `<div {{with .Get 0}} class="{{ . }}"{{ end }}>{{ .Inner }}</div>`)

	CheckShortCodeMatch(t,
		`{{% acc %}}{{% div %}}d1{{% /div %}}{{% div2 %}}d2{{% /div2 %}}{{% /acc %}}`,
		"<div class=\"acc\"><div >d1</div><div >d2</div>\n</div>", tem)
}
开发者ID:vincentsys,项目名称:hugo,代码行数:11,代码来源:shortcode_test.go


示例13: TestPositionalParamSC

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, "{{<video 47238zzb>}}", "Playing Video 47238zzb", tem)
	CheckShortCodeMatch(t, "{{<video 47238zzb    >}}", "Playing Video 47238zzb", tem)
	CheckShortCodeMatch(t, "{{<   video   47238zzb    >}}", "Playing Video 47238zzb", tem)
}
开发者ID:highPriestLOL,项目名称:hugo,代码行数:10,代码来源:shortcode_test.go


示例14: TestInnerSCWithMarkdown

func TestInnerSCWithMarkdown(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("inside.html", `<div{{with .Get "class"}} class="{{.}}"{{end}}>{{ .Inner }}</div>`)

	CheckShortCodeMatch(t, `{{% inside %}}
# More Here

[link](http://spf13.com) and text

{{% /inside %}}`, "<div><h1 id=\"more-here:bec3ed8ba720b9073ab75abcf3ba5d97\">More Here</h1>\n\n<p><a href=\"http://spf13.com\">link</a> and text</p>\n</div>", tem)
}
开发者ID:highPriestLOL,项目名称:hugo,代码行数:11,代码来源:shortcode_test.go


示例15: TestNamedParamSC

func TestNamedParamSC(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("img.html", `<img{{ with .Get "src" }} src="{{.}}"{{end}}{{with .Get "class"}} class="{{.}}"{{end}}>`)

	CheckShortCodeMatch(t, `{{< img src="one" >}}`, `<img src="one">`, tem)
	CheckShortCodeMatch(t, `{{< img class="aspen" >}}`, `<img class="aspen">`, tem)
	CheckShortCodeMatch(t, `{{< img src= "one" >}}`, `<img src="one">`, tem)
	CheckShortCodeMatch(t, `{{< img src ="one" >}}`, `<img src="one">`, tem)
	CheckShortCodeMatch(t, `{{< img src = "one" >}}`, `<img src="one">`, tem)
	CheckShortCodeMatch(t, `{{< img src = "one" class = "aspen grove" >}}`, `<img src="one" class="aspen grove">`, tem)
}
开发者ID:highPriestLOL,项目名称:hugo,代码行数:11,代码来源:shortcode_test.go


示例16: TestIsNamedParamsSC

func TestIsNamedParamsSC(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("byposition.html", `<div id="{{ .Get 0 }}">`)
	tem.AddInternalShortcode("byname.html", `<div id="{{ .Get "id" }}">`)
	tem.AddInternalShortcode("ifnamedparams.html", `<div id="{{ if .IsNamedParams }}{{ .Get "id" }}{{ else }}{{ .Get 0 }}{{end}}">`)

	CheckShortCodeMatch(t, `{{< ifnamedparams id="name" >}}`, `<div id="name">`, tem)
	CheckShortCodeMatch(t, `{{< ifnamedparams position >}}`, `<div id="position">`, tem)
	CheckShortCodeMatch(t, `{{< byname id="name" >}}`, `<div id="name">`, tem)
	CheckShortCodeMatch(t, `{{< byname position >}}`, `<div id="error: cannot access positional params by string name">`, tem)
	CheckShortCodeMatch(t, `{{< byposition position >}}`, `<div id="position">`, tem)
	CheckShortCodeMatch(t, `{{< byposition id="name" >}}`, `<div id="error: cannot access named params by position">`, tem)
}
开发者ID:xinzhi,项目名称:hugo,代码行数:13,代码来源:shortcode_test.go


示例17: TestNestedComplexSC

func TestNestedComplexSC(t *testing.T) {
	tem := tpl.New()
	tem.AddInternalShortcode("row.html", `-row-{{ .Inner}}-rowStop-`)
	tem.AddInternalShortcode("column.html", `-col-{{.Inner    }}-colStop-`)
	tem.AddInternalShortcode("aside.html", `-aside-{{    .Inner  }}-asideStop-`)

	CheckShortCodeMatch(t, `{{< row >}}1-s{{% column %}}2-**s**{{< aside >}}3-**s**{{< /aside >}}4-s{{% /column %}}5-s{{< /row >}}6-s`,
		"-row-1-s-col-2-<strong>s</strong>-aside-3-<strong>s</strong>-asideStop-4-s-colStop-5-s-rowStop-6-s", tem)

	// turn around the markup flag
	CheckShortCodeMatch(t, `{{% row %}}1-s{{< column >}}2-**s**{{% aside %}}3-**s**{{% /aside %}}4-s{{< /column >}}5-s{{% /row %}}6-s`,
		"-row-1-s-col-2-<strong>s</strong>-aside-3-<strong>s</strong>-asideStop-4-s-colStop-5-s-rowStop-6-s", tem)
}
开发者ID:highPriestLOL,项目名称:hugo,代码行数:13,代码来源:shortcode_test.go


示例18: TestHighlight

func TestHighlight(t *testing.T) {
	if !helpers.HasPygments() {
		t.Skip("Skip test as Pygments is not installed")
	}
	defer viper.Set("PygmentsStyle", viper.Get("PygmentsStyle"))
	viper.Set("PygmentsStyle", "bw")

	tem := tpl.New()

	code := `
{{< highlight java >}}
void do();
{{< /highlight >}}`
	CheckShortCodeMatch(t, code, "\n<div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span style=\"font-weight: bold\">void</span> do();\n</pre></div>\n", tem)
}
开发者ID:jaden,项目名称:hugo,代码行数:15,代码来源:shortcode_test.go


示例19: TestShortcodeHighlight

func TestShortcodeHighlight(t *testing.T) {
	viper.Reset()
	defer viper.Reset()

	if !helpers.HasPygments() {
		t.Skip("Skip test as Pygments is not installed")
	}
	viper.Set("PygmentsStyle", "bw")
	viper.Set("PygmentsUseClasses", false)

	for i, this := range []struct {
		in, expected string
	}{
		{`
{{< highlight java >}}
void do();
{{< /highlight >}}`,
			"(?s)^\n<div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\">.*?void</span> do().*?</pre></div>\n$",
		},
		{`
{{< highlight java "style=friendly" >}}
void do();
{{< /highlight >}}`,
			"(?s)^\n<div class=\"highlight\" style=\"background: #f0f0f0\"><pre style=\"line-height: 125%\">.*?void</span>.*?do</span>.*?().*?</pre></div>\n$",
		},
	} {
		templ := tpl.New()
		p, _ := pageFromString(simplePage, "simple.md")
		output, err := HandleShortcodes(this.in, p, templ)

		if err != nil {
			t.Fatalf("[%d] Handle shortcode error", i)
		}

		matched, err := regexp.MatchString(this.expected, output)

		if err != nil {
			t.Fatalf("[%d] Regexp error", i)
		}

		if !matched {
			t.Errorf("[%d] Hightlight mismatch, got %s\n", i, output)
		}
	}
}
开发者ID:vincentsys,项目名称:hugo,代码行数:45,代码来源:embedded_shortcodes_test.go


示例20: TestShortcodeTweet

func TestShortcodeTweet(t *testing.T) {
	for i, this := range []struct {
		in, resp, expected string
	}{
		{
			`{{< tweet 666616452582129664 >}}`,
			`{"url":"https:\/\/twitter.com\/spf13\/status\/666616452582129664","author_name":"Steve Francia","author_url":"https:\/\/twitter.com\/spf13","html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EHugo 0.15 will have 30%+ faster render times thanks to this commit \u003Ca href=\"https:\/\/t.co\/FfzhM8bNhT\"\u003Ehttps:\/\/t.co\/FfzhM8bNhT\u003C\/a\u003E  \u003Ca href=\"https:\/\/twitter.com\/hashtag\/gohugo?src=hash\"\u003E#gohugo\u003C\/a\u003E \u003Ca href=\"https:\/\/twitter.com\/hashtag\/golang?src=hash\"\u003E#golang\u003C\/a\u003E \u003Ca href=\"https:\/\/t.co\/ITbMNU2BUf\"\u003Ehttps:\/\/t.co\/ITbMNU2BUf\u003C\/a\u003E\u003C\/p\u003E&mdash; Steve Francia (@spf13) \u003Ca href=\"https:\/\/twitter.com\/spf13\/status\/666616452582129664\"\u003ENovember 17, 2015\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E","width":550,"height":null,"type":"rich","cache_age":"3153600000","provider_name":"Twitter","provider_url":"https:\/\/twitter.com","version":"1.0"}`,
			`(?s)^<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Hugo 0.15 will have 30%. faster render times thanks to this commit <a href="https://t.co/FfzhM8bNhT">https://t.co/FfzhM8bNhT</a>  <a href="https://twitter.com/hashtag/gohugo.src=hash">#gohugo</a> <a href="https://twitter.com/hashtag/golang.src=hash">#golang</a> <a href="https://t.co/ITbMNU2BUf">https://t.co/ITbMNU2BUf</a></p>&mdash; Steve Francia [email protected] <a href="https://twitter.com/spf13/status/666616452582129664">November 17, 2015</a></blockquote>.*?<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>$`,
		},
	} {
		// overload getJSON to return mock API response from Twitter
		tweetFuncMap := template.FuncMap{
			"getJSON": func(urlParts ...string) interface{} {
				var v interface{}
				err := json.Unmarshal([]byte(this.resp), &v)
				if err != nil {
					t.Fatalf("[%d] unexpected error in json.Unmarshal: %s", i, err)
					return err
				}
				return v
			},
		}

		templ := tpl.New()
		templ.Lookup("").Funcs(tweetFuncMap)

		p, _ := pageFromString(simplePage, "simple.md")
		cacheFileID := viper.GetString("CacheDir") + url.QueryEscape("https://api.twitter.com/1/statuses/oembed.json?id=666616452582129664")
		defer os.Remove(cacheFileID)
		output, err := HandleShortcodes(this.in, p, templ)

		matched, err := regexp.MatchString(this.expected, output)

		if err != nil {
			t.Fatalf("[%d] Regexp error", i)
		}

		if !matched {
			t.Errorf("[%d] unexpected rendering, got %s\n", i, output)
		}
	}
}
开发者ID:tarsisazevedo,项目名称:hugo,代码行数:42,代码来源:embedded_shortcodes_test.go



注:本文中的github.com/spf13/hugo/tpl.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang transform.NewChain函数代码示例发布时间:2022-05-28
下一篇:
Golang tpl.ExecuteTemplateToHTML函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap