summaryrefslogtreecommitdiff
path: root/specs/comments.yml
blob: c019666b3cf343b8c507f3ab7b78cfad66f2acf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
overview: |
  Comment tags represent content that should never appear in the resulting
  output.

  The tag's content may contain any substring (including newlines) EXCEPT the
  closing delimiter.

  Comment tags SHOULD be treated as standalone when appropriate.
tests:
  - name: Inline
    desc: Comment blocks should be removed from the template.
    data: { }
    template: '12345{{! Comment Block! }}67890'
    expected: '1234567890'

  - name: Multiline
    desc: Multiline comments should be permitted.
    data: { }
    template: |
      12345{{!
        This is a
        multi-line comment...
      }}67890
    expected: |
      1234567890

  - name: Standalone
    desc: All standalone comment lines should be removed.
    data: { }
    template: |
      Begin.
      {{! Comment Block! }}
      End.
    expected: |
      Begin.
      End.

  - name: Indented Standalone
    desc: All standalone comment lines should be removed.
    data: { }
    template: |
      Begin.
        {{! Indented Comment Block! }}
      End.
    expected: |
      Begin.
      End.

  - name: Standalone Line Endings
    desc: '"\r\n" should be considered a newline for standalone tags.'
    data: { }
    template: "|\r\n{{! Standalone Comment }}\r\n|"
    expected: "|\r\n|"

  - name: Multiline Standalone
    desc: All standalone comment lines should be removed.
    data: { }
    template: |
      Begin.
      {{!
      Something's going on here...
      }}
      End.
    expected: |
      Begin.
      End.

  - name: Indented Multiline Standalone
    desc: All standalone comment lines should be removed.
    data: { }
    template: |
      Begin.
        {{!
          Something's going on here...
        }}
      End.
    expected: |
      Begin.
      End.

  - name: Indented Inline
    desc: Inline comments should not strip whitespace
    data: { }
    template: "  12 {{! 34 }}\n"
    expected: "  12 \n"

  - name: Surrounding Whitespace
    desc: Comment removal should preserve surrounding whitespace.
    data: { }
    template: '12345 {{! Comment Block! }} 67890'
    expected: '12345  67890'