tests: - name: Falsey desc: Falsey sections should have their contents rendered. data: { boolean: false } template: '"{{^boolean}}This should be rendered.{{/boolean}}"' expected: '"This should be rendered."' - name: Truthy desc: Truthy sections should have their contents omitted. data: { boolean: true } template: '"{{^boolean}}This should not be rendered.{{/boolean}}"' expected: '""' - name: Context desc: Objects and hashes should behave like truthy values. data: { context: { name: 'Joe' } } template: '"{{^context}}Hi {{name}}.{{/context}}"' expected: '""' - name: List desc: Lists should behave like truthy values. data: { list: [ { n: 1 }, { n: 2 }, { n: 3 } ] } template: '"{{^list}}{{n}}{{/list}}"' expected: '""' - name: Empty List desc: Empty lists should behave like falsey values. data: { list: [ ] } template: '"{{^list}}Yay lists!{{/list}}"' expected: '"Yay lists!"' - name: Doubled desc: Multiple inverted sections per template should be permitted. data: { t: false, two: 'second' } template: | {{^t}} * first {{/t}} * {{two}} {{^t}} * third {{/t}} expected: | * first * second * third - name: Nested (Falsey) desc: Nested falsey sections should have their contents rendered. data: { t: false } template: "| A {{^t}}B {{^t}}C{{/t}} D{{/t}} E |" expected: "| A B C D E |" - name: Nested (Truthy) desc: Nested truthy sections should be omitted. data: { t: true } template: "| A {{^t}}B {{^t}}C{{/t}} D{{/t}} E |" expected: "| A E |" # Whitespace Sensitivity - name: Surrounding Whitespace desc: Inverted sections should not alter surrounding whitespace. data: { boolean: false } template: " | {{^boolean}}\t|\t{{/boolean}} | \n" expected: " | \t|\t | \n" - name: Internal Whitespace desc: Inverted should not alter internal whitespace. data: { boolean: false } template: " | {{^boolean}} {{! Important Whitespace }}\n {{/boolean}} | \n" expected: " | \n | \n" - name: Standalone Lines desc: Standalone lines should be removed from the template. data: { boolean: false } template: | | This Is {{^boolean}} | {{/boolean}} | A Line expected: | | This Is | | A Line - name: Standalone Indented Lines desc: Standalone indented lines should be removed from the template. data: { boolean: false } template: | | This Is {{^boolean}} | {{/boolean}} | A Line expected: | | This Is | | A Line # Whitespace Insensitivity - name: Padding desc: Superfluous in-tag whitespace should be ignored. data: { boolean: false } template: '|{{^ boolean }}={{/ boolean }}|' expected: '|=|'