The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
overview: |
  Set Delimiter tags are used to change the tag delimiters for all content
  following the tag in the current compilation unit.

  The tag's content MUST be any two non-whitespace sequences (separated by
  whitespace) EXCEPT an equals sign ('=') followed by the current closing
  delimiter.

  Set Delimiter tags SHOULD be treated as standalone when appropriate.
tests:
  - name: Pair Behavior
    desc: The equals sign (used on both sides) should permit delimiter changes.
    data: { text: 'Hey!' }
    template: '{{=<% %>=}}(<%text%>)'
    expected: '(Hey!)'

  - name: Special Characters
    desc: Characters with special meaning regexen should be valid delimiters.
    data: { text: 'It worked!' }
    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
    desc: Surrounding whitespace should be left untouched.
    data: { }
    template: '| {{=@ @=}} |'
    expected: '|  |'

  - name: Outlying Whitespace (Inline)
    desc: Whitespace should be left untouched.
    data: { }
    template: " | {{=@ @=}}\n"
    expected: " | \n"

  - name: Standalone Tag
    desc: Standalone lines should be removed from the template.
    data: { }
    template: |
      Begin.
      {{=@ @=}}
      End.
    expected: |
      Begin.
      End.

  - name: Indented Standalone Tag
    desc: Indented standalone lines should be removed from the template.
    data: { }
    template: |
      Begin.
        {{=@ @=}}
      End.
    expected: |
      Begin.
      End.

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

  - name: Standalone Without Previous Line
    desc: Standalone tags should not require a newline to precede them.
    data: { }
    template: "  {{=@ @=}}\n="
    expected: "="

  - name: Standalone Without Newline
    desc: Standalone tags should not require a newline to follow them.
    data: { }
    template: "=\n  {{=@ @=}}"
    expected: "=\n"

  # Whitespace Insensitivity

  - name: Pair with Padding
    desc: Superfluous in-tag whitespace should be ignored.
    data: { }
    template: '|{{= @   @ =}}|'
    expected: '||'