delimiters.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. overview: |
  2. Set Delimiter tags are used to change the tag delimiters for all content
  3. following the tag in the current compilation unit.
  4. The tag's content MUST be any two non-whitespace sequences (separated by
  5. whitespace) EXCEPT an equals sign ('=') followed by the current closing
  6. delimiter.
  7. Set Delimiter tags SHOULD be treated as standalone when appropriate.
  8. tests:
  9. - name: Pair Behavior
  10. desc: The equals sign (used on both sides) should permit delimiter changes.
  11. data: { text: 'Hey!' }
  12. template: '{{=<% %>=}}(<%text%>)'
  13. expected: '(Hey!)'
  14. - name: Special Characters
  15. desc: Characters with special meaning regexen should be valid delimiters.
  16. data: { text: 'It worked!' }
  17. template: '({{=[ ]=}}[text])'
  18. expected: '(It worked!)'
  19. - name: Sections
  20. desc: Delimiters set outside sections should persist.
  21. data: { section: true, data: 'I got interpolated.' }
  22. template: |
  23. [
  24. {{#section}}
  25. {{data}}
  26. |data|
  27. {{/section}}
  28. {{= | | =}}
  29. |#section|
  30. {{data}}
  31. |data|
  32. |/section|
  33. ]
  34. expected: |
  35. [
  36. I got interpolated.
  37. |data|
  38. {{data}}
  39. I got interpolated.
  40. ]
  41. - name: Inverted Sections
  42. desc: Delimiters set outside inverted sections should persist.
  43. data: { section: false, data: 'I got interpolated.' }
  44. template: |
  45. [
  46. {{^section}}
  47. {{data}}
  48. |data|
  49. {{/section}}
  50. {{= | | =}}
  51. |^section|
  52. {{data}}
  53. |data|
  54. |/section|
  55. ]
  56. expected: |
  57. [
  58. I got interpolated.
  59. |data|
  60. {{data}}
  61. I got interpolated.
  62. ]
  63. - name: Partial Inheritence
  64. desc: Delimiters set in a parent template should not affect a partial.
  65. data: { value: 'yes' }
  66. partials:
  67. include: '.{{value}}.'
  68. template: |
  69. [ {{>include}} ]
  70. {{= | | =}}
  71. [ |>include| ]
  72. expected: |
  73. [ .yes. ]
  74. [ .yes. ]
  75. - name: Post-Partial Behavior
  76. desc: Delimiters set in a partial should not affect the parent template.
  77. data: { value: 'yes' }
  78. partials:
  79. include: '.{{value}}. {{= | | =}} .|value|.'
  80. template: |
  81. [ {{>include}} ]
  82. [ .{{value}}. .|value|. ]
  83. expected: |
  84. [ .yes. .yes. ]
  85. [ .yes. .|value|. ]
  86. # Whitespace Sensitivity
  87. - name: Surrounding Whitespace
  88. desc: Surrounding whitespace should be left untouched.
  89. data: { }
  90. template: '| {{=@ @=}} |'
  91. expected: '| |'
  92. - name: Outlying Whitespace (Inline)
  93. desc: Whitespace should be left untouched.
  94. data: { }
  95. template: " | {{=@ @=}}\n"
  96. expected: " | \n"
  97. - name: Standalone Tag
  98. desc: Standalone lines should be removed from the template.
  99. data: { }
  100. template: |
  101. Begin.
  102. {{=@ @=}}
  103. End.
  104. expected: |
  105. Begin.
  106. End.
  107. - name: Indented Standalone Tag
  108. desc: Indented standalone lines should be removed from the template.
  109. data: { }
  110. template: |
  111. Begin.
  112. {{=@ @=}}
  113. End.
  114. expected: |
  115. Begin.
  116. End.
  117. - name: Standalone Line Endings
  118. desc: '"\r\n" should be considered a newline for standalone tags.'
  119. data: { }
  120. template: "|\r\n{{= @ @ =}}\r\n|"
  121. expected: "|\r\n|"
  122. - name: Standalone Without Previous Line
  123. desc: Standalone tags should not require a newline to precede them.
  124. data: { }
  125. template: " {{=@ @=}}\n="
  126. expected: "="
  127. - name: Standalone Without Newline
  128. desc: Standalone tags should not require a newline to follow them.
  129. data: { }
  130. template: "=\n {{=@ @=}}"
  131. expected: "=\n"
  132. # Whitespace Insensitivity
  133. - name: Pair with Padding
  134. desc: Superfluous in-tag whitespace should be ignored.
  135. data: { }
  136. template: '|{{= @ @ =}}|'
  137. expected: '||'