From 31029bf50bcafac02f8c663ac87e5472306539d4 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 2 May 2020 17:54:26 -0400 Subject: [PATCH] Add a test for whitespace inside the template. This is similar to the surrounding whitespace test but for whitespace inside of a tag as opposed to before/after the first element of the template. --- js/test_cases/internal_whitespace/README.md | 37 +++++ js/test_cases/internal_whitespace/input1.json | 1 + js/test_cases/internal_whitespace/main.dust | 138 ++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 js/test_cases/internal_whitespace/README.md create mode 100644 js/test_cases/internal_whitespace/input1.json create mode 100644 js/test_cases/internal_whitespace/main.dust diff --git a/js/test_cases/internal_whitespace/README.md b/js/test_cases/internal_whitespace/README.md new file mode 100644 index 0000000..4d6143d --- /dev/null +++ b/js/test_cases/internal_whitespace/README.md @@ -0,0 +1,37 @@ +Through experimentation I have determined that DustJS: + +- Ignores newlines entirely (probably why there is a special character for newlines) +- Ignores spaces on empty lines +- Ignore tabs on empty lines +- Honors interior tabs +- Honors interior spaces +- Honors trailing spaces on opening, body, and closing tags +- Honors trailing spaces on tagless lines with content +- Honors trailing tabs on opening, body, and closing tags +- Honors trailing tabs on tagless lines with content +- Ignores leading spaces on opening, body, and closing tags +- Ignores leading spaces on tagless lines with content +- Ignores leading tabs on opening, body, and closing tags +- Ignores leading tabs on tagless lines with content + +Definitions +----------- + +Interior: Surounnded by tags on the same line: +``` +{foo}this is interior{/foo} +``` + +Trailing: On a line with a tag but no tag following it on that line: +``` +{stuff} +{name}this is trailing +{other stuff} +``` + +Leading: On a line with a tag but no tag preceding it on that line: +``` +{stuff} +this is leading{name} +{other stuff} +``` diff --git a/js/test_cases/internal_whitespace/input1.json b/js/test_cases/internal_whitespace/input1.json new file mode 100644 index 0000000..fee95a9 --- /dev/null +++ b/js/test_cases/internal_whitespace/input1.json @@ -0,0 +1 @@ +{"names": ["Alice", "Bob", "Chris"]} diff --git a/js/test_cases/internal_whitespace/main.dust b/js/test_cases/internal_whitespace/main.dust new file mode 100644 index 0000000..99e602c --- /dev/null +++ b/js/test_cases/internal_whitespace/main.dust @@ -0,0 +1,138 @@ +- simple -{~n} +{#names}{.}{/names} +{~n}- new lines -{~n} +{#names} +{.} +{/names} + +{~n}- interior tabs -{~n} +{#names} {.} {/names} + +{~n}- interior spaces -{~n} +{#names} {.} {/names} + +{~n}- empty line with spaces -{~n} +{#names} + +{/names} + +{~n}- empty line with tabs -{~n} +{#names} + +{/names} + +{~n}- empty line with spaces, trailing spaces on opening and closing -{~n} +{#names} + +{/names} + +{~n}- no line, trailing spaces on opening and closing -{~n} +{#names} +{/names} + +{~n}- empty line, trailing spaces on opening and closing -{~n} +{#names} + +{/names} + +{~n}- trailing spaces -{~n} +{#names} +{.} +{/names} + +{~n}- tagless line trailing spaces -{~n} +{#names} + +{/names} +{#names} +line with content but no tag +{/names} + +{~n}- empty line with tabs, trailing tabs on opening and closing -{~n} +{#names} + +{/names} + +{~n}- no line, trailing tabs on opening and closing -{~n} +{#names} +{/names} + +{~n}- empty line, trailing tabs on opening and closing -{~n} +{#names} + +{/names} + +{~n}- trailing tabs -{~n} +{#names} +{.} +{/names} + +{~n}- tagless line trailing tabs -{~n} +{#names} + +{/names} +{#names} +line with content but no tag +{/names} + + + + + + + + + +{~n}- empty line with spaces, leading spaces on opening and closing -{~n} + {#names} + + {/names} + +{~n}- no line, leading spaces on opening and closing -{~n} + {#names} + {/names} + +{~n}- empty line, leading spaces on opening and closing -{~n} + {#names} + + {/names} + +{~n}- leading spaces -{~n} + {#names} + {.} + {/names} + +{~n}- tagless line leading spaces -{~n} +{#names} + +{/names} +{#names} + line with content but no tag +{/names} + +{~n}- empty line with tabs, leading tabs on opening and closing -{~n} + {#names} + + {/names} + +{~n}- no line, leading tabs on opening and closing -{~n} + {#names} + {/names} + +{~n}- empty line, leading tabs on opening and closing -{~n} + {#names} + + {/names} + +{~n}- leading tabs -{~n} + {#names} + {.} + {/names} + +{~n}- tagless line leading tabs -{~n} +{#names} + +{/names} +{#names} + line with content but no tag +{/names}