Fix identation with section segments

This commit is contained in:
Adam Gent
2023-11-27 13:27:58 -05:00
parent 57f182c157
commit 388406eab5
4 changed files with 181 additions and 37 deletions
@@ -31,7 +31,7 @@ public abstract class SpecTest {
public void test () throws Exception {
//System.out.println("Testing: " + name);
SpecAwareTemplateLoader loader = new SpecAwareTemplateLoader(spec);
Mustache.Compiler compiler = Mustache.compiler().defaultValue("").withLoader(loader);
Mustache.Compiler compiler = Mustache.compiler().emptyStringIsFalse(true).defaultValue("").withLoader(loader);
String tmpl = spec.getTemplate();
String desc = String.format("Template: '''%s'''\nData: '%s'\n",
uncrlf(tmpl), uncrlf(spec.getData().toString()));
+74 -3
View File
@@ -24,8 +24,8 @@ tests:
nest: "2\n{{{content}}}\n2\n"
expected: "|\n 1\n 2\n <\n->\n 2\n 1\n|\n"
- name: Standalone Indentation
desc: Each line of the partial should be indented before rendering.
- name: Partial Section Indentation End Content
desc: Closing end sections that have content on same line should be indented
data: { content: "<\n->" }
template: |
\
@@ -34,12 +34,83 @@ tests:
partials:
partial: |
|
{{{content}}}
{{#content}}
{{{.}}}
{{/content}}-
|
expected: |
\
|
<
->
-
|
/
- name: Partial Section Indentation Inside Start Content
desc: Content that is not white space on same line as section start tag inside should be indented
data: { content: "<\n->" }
template: |
\
{{>partial}}
/
partials:
partial: |
|
{{#content}}-
{{{.}}}
{{/content}}
|
expected: |
\
|
-
<
->
|
/
- name: Partial Section Indentation Start Content
desc: Content that is not white space on same line as section start tags should be indented
data: { content: "<\n->" }
template: |
\
{{>partial}}
/
partials:
partial: |
|
-{{#content}}
{{{.}}}
{{/content}}
|
expected: |
\
|
-
<
->
|
/
- name: Partial Indentation With Empty Sections
desc: Empty standlone sections should not have indentation before or after
data: { content: "" }
template: |
\
{{>partial}}
/
partials:
partial: |
|
{{#content}}
{{{.}}}
{{/content}}
|
expected: |
\
|
|
/
# The extra newline on the end is required