Permalink
Browse files

Adding a few specs for the Set Delimiter tags.

Generalized, these tests ensure that delimiter context does
not extend across compilation unit boundaries, and that naïve
template caching mechanisms don't behave unexpectedly around
changing delimiters.
  • Loading branch information...
pvande committed Dec 21, 2010
1 parent 3d01a7b commit 61d47607a9156ce0c49d12a3d7cf9e46ea1a6c68
Showing with 75 additions and 0 deletions.
  1. +75 −0 specs/delimiters.yml
View
@@ -11,6 +11,81 @@ tests:
template: '({{=[ ]=}}[text])'
expected: '(It worked!)'
+ - name: Sections
+ desc: Delimiters set outside sections should persist.
+ data: { section: true, data: 'I got interpolated.' }
+ template: |
+ [
+ {{#section}}
+ {{data}}
+ |data|
+ {{/section}}
+
+ {{= | | =}}
+ |#section|
+ {{data}}
+ |data|
+ |/section|
+ ]
+ expected: |
+ [
+ I got interpolated.
+ |data|
+
+ {{data}}
+ I got interpolated.
+ ]
+
+ - name: Inverted Sections
+ desc: Delimiters set outside inverted sections should persist.
+ data: { section: false, data: 'I got interpolated.' }
+ template: |
+ [
+ {{^section}}
+ {{data}}
+ |data|
+ {{/section}}
+
+ {{= | | =}}
+ |^section|
+ {{data}}
+ |data|
+ |/section|
+ ]
+ expected: |
+ [
+ I got interpolated.
+ |data|
+
+ {{data}}
+ I got interpolated.
+ ]
+
+ - name: Partial Inheritence
+ desc: Delimiters set in a parent template should not affect a partial.
+ data: { value: 'yes' }
+ partials:
+ include: '.{{value}}.'
+ template: |
+ [ {{>include}} ]
+ {{= | | =}}
+ [ |>include| ]
+ expected: |
+ [ .yes. ]
+ [ .yes. ]
+
+ - name: Post-Partial Behavior
+ desc: Delimiters set in a partial should not affect the parent template.
+ data: { value: 'yes' }
+ partials:
+ include: '.{{value}}. {{= | | =}} .|value|.'
+ template: |
+ [ {{>include}} ]
+ [ .{{value}}. .|value|. ]
+ expected: |
+ [ .yes. .yes. ]
+ [ .yes. .|value|. ]
+
# Whitespace Sensitivity
- name: Surrounding Whitespace

0 comments on commit 61d4760

Please sign in to comment.