diff --git a/partial_helper_test.go b/partial_helper_test.go index dde5932..bd808b1 100644 --- a/partial_helper_test.go +++ b/partial_helper_test.go @@ -234,6 +234,48 @@ func Test_PartialHelper_Javascript_With_HTML(t *testing.T) { r.Equal(`alert(\'\\\'Hello\\\'\');`, string(html)) } +func Test_PartialHelper_Javascript_With_HTML_Partial(t *testing.T) { + // https://github.com/gobuffalo/plush/issues/106 + r := require.New(t) + + data := map[string]interface{}{} + help := HelperContext{Context: NewContext()} + help.Set("partialFeeder", func(name string) (string, error) { + switch name { + case "js_having_html_partial.js": + return `alert('<%= partial("t1.html") %>');`, nil + case "js_having_js_partial.js": + return `alert('<%= partial("t1.js") %>');`, nil + case "t1.html": + return `
This is a test
`, strings.TrimSpace(string(html))) } +func Test_PartialHelpers_Markdown_With_Nested_CodeBlock(t *testing.T) { + // for https://github.com/gobuffalo/plush/issues/82 + r := require.New(t) + + main := `<%= partial("outer.md") %>` + outer := `Some text + +<%= partial("inner.md") %> +` + inner := "```go\n" + `if true { + fmt.Println() +}` + "\n```" + + help := HelperContext{Context: NewContext()} + help.Set("contentType", "text/markdown") + help.Set("partialFeeder", func(name string) (string, error) { + if name == "outer.md" { + return outer, nil + } + return inner, nil + }) + + html, err := Render(main, help) + r.NoError(err) + r.Equal(`Some text
+ +if true {
+ fmt.Println()
+}
+