summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/templates/tplcontext_test.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2020-06-15 14:38:51 -0400
committerGitHub <noreply@github.com>2020-06-15 12:38:51 -0600
commit003403ecbccbd3fa53040ee1f0fd5d411a887215 (patch)
tree0ae9f006c64787db59ffb8860bb4e89210d09623 /modules/caddyhttp/templates/tplcontext_test.go
parent5b48f784ae45cdeb7161e85f274283327cde24e7 (diff)
templates: Add support for dots to close yaml frontmatter (#3498)
* templates: Add support for dots to close yaml frontmatter * templates: Fix regression in body output
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext_test.go')
-rw-r--r--modules/caddyhttp/templates/tplcontext_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go
index 4c3da03..f90b851 100644
--- a/modules/caddyhttp/templates/tplcontext_test.go
+++ b/modules/caddyhttp/templates/tplcontext_test.go
@@ -290,11 +290,13 @@ func TestSplitFrontMatter(t *testing.T) {
for i, test := range []struct {
input string
expect string
+ body string
}{
{
// yaml with windows newline
input: "---\r\ntitle: Welcome\r\n---\r\n# Test\\r\\n",
expect: `Welcome`,
+ body: "\r\n# Test\\r\\n",
},
{
// yaml
@@ -303,6 +305,16 @@ title: Welcome
---
### Test`,
expect: `Welcome`,
+ body: "\n### Test",
+ },
+ {
+ // yaml with dots for closer
+ input: `---
+title: Welcome
+...
+### Test`,
+ expect: `Welcome`,
+ body: "\n### Test",
},
{
// toml
@@ -311,6 +323,7 @@ title = "Welcome"
+++
### Test`,
expect: `Welcome`,
+ body: "\n### Test",
},
{
// json
@@ -319,12 +332,16 @@ title = "Welcome"
}
### Test`,
expect: `Welcome`,
+ body: "\n### Test",
},
} {
result, _ := context.funcSplitFrontMatter(test.input)
if result.Meta["title"] != test.expect {
t.Errorf("Test %d: Expected %s, found %s. Input was SplitFrontMatter(%s)", i, test.expect, result.Meta["title"], test.input)
}
+ if result.Body != test.body {
+ t.Errorf("Test %d: Expected body %s, found %s. Input was SplitFrontMatter(%s)", i, test.body, result.Body, test.input)
+ }
}
}