• passes: 25
  • failures: 0
  • duration: 0.03s
  • Template loading

    • String template0ms ‣

      expect(tmpl('{%=o.value%}', data)).to.equal('value')
    • Load template by id0ms ‣

      expect(tmpl('template', data)).to.equal('value')
    • Retun function when called without data parameter0ms ‣

      expect(tmpl('{%=o.value%}')(data)).to.equal('value')
    • Cache templates loaded by id1ms ‣

      tmpl('template')
      expect(tmpl.cache.template).to.be.a('function')
  • Interpolation

    • Escape HTML special characters with {%=o.prop%}0ms ‣

      expect(tmpl('{%=o.special%}', data)).to.equal('<>&"'')
    • Allow HTML special characters with {%#o.prop%}0ms ‣

      expect(tmpl('{%#o.special%}', data)).to.equal('<>&"\'\x00')
    • Function call0ms ‣

      expect(tmpl('{%=o.func()%}', data)).to.equal('value')
    • Dot notation0ms ‣

      expect(tmpl('{%=o.deep.value%}', data)).to.equal('value')
    • Handle single quotes0ms ‣

      expect(tmpl("'single quotes'{%=\": '\"%}", data)).to.equal(
        "'single quotes': &#39;"
      )
    • Handle double quotes0ms ‣

      expect(tmpl('"double quotes"{%=": \\""%}', data)).to.equal(
        '"double quotes": &quot;'
      )
    • Handle backslashes0ms ‣

      expect(tmpl('\\backslashes\\{%=": \\\\"%}', data)).to.equal(
        '\\backslashes\\: \\'
      )
    • Interpolate escaped falsy values except undefined or null0ms ‣

      expect(
        tmpl(
          '{%=o.undefinedValue%}' +
            '{%=o.nullValue%}' +
            '{%=o.falseValue%}' +
            '{%=o.zeroValue%}',
          data
        )
      ).to.equal('false0')
    • Interpolate unescaped falsy values except undefined or null1ms ‣

      expect(
        tmpl(
          '{%#o.undefinedValue%}' +
            '{%#o.nullValue%}' +
            '{%#o.falseValue%}' +
            '{%#o.zeroValue%}',
          data
        )
      ).to.equal('false0')
    • Preserve whitespace0ms ‣

      expect(tmpl('\n\r\t{%=o.value%}  \n\r\t{%=o.value%}  ', data)).to.equal(
        '\n\r\tvalue  \n\r\tvalue  '
      )
  • Evaluation

    • Escape HTML special characters with print(data)0ms ‣

      expect(tmpl('{% print(o.special); %}', data)).to.equal(
        '&lt;&gt;&amp;&quot;&#39;'
      )
    • Allow HTML special characters with print(data, true)0ms ‣

      expect(tmpl('{% print(o.special, true); %}', data)).to.equal('<>&"\'\x00')
    • Print out escaped falsy values except undefined or null0ms ‣

      expect(
        tmpl(
          '{% print(o.undefinedValue); %}' +
            '{% print(o.nullValue); %}' +
            '{% print(o.falseValue); %}' +
            '{% print(o.zeroValue); %}',
          data
        )
      ).to.equal('false0')
    • Print out unescaped falsy values except undefined or null0ms ‣

      expect(
        tmpl(
          '{% print(o.undefinedValue, true); %}' +
            '{% print(o.nullValue, true); %}' +
            '{% print(o.falseValue, true); %}' +
            '{% print(o.zeroValue, true); %}',
          data
        )
      ).to.equal('false0')
    • Include template0ms ‣

      expect(
        tmpl('{% include("template", {value: "value"}); %}', data)
      ).to.equal('value')
    • If condition0ms ‣

      expect(
        tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data)
      ).to.equal('true')
    • Else condition0ms ‣

      expect(
        tmpl(
          '{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}',
          data
        )
      ).to.equal('true')
    • For loop0ms ‣

      expect(
        tmpl(
          '{% for (var i=0; i<o.list.length; i++) { %}' +
            '{%=o.list[i]%}{% } %}',
          data
        )
      ).to.equal('12345')
    • For loop print call0ms ‣

      expect(
        tmpl(
          '{% for (var i=0; i<o.list.length; i++) {' + 'print(o.list[i]);} %}',
          data
        )
      ).to.equal('12345')
    • For loop include template0ms ‣

      expect(
        tmpl(
          '{% for (var i=0; i<o.list.length; i++) {' +
            'include("template", {value: o.list[i]});} %}',
          data
        ).replace(/[\r\n]/g, '')
      ).to.equal('12345')
    • Modulo operator0ms ‣

      expect(
        tmpl(
          '{% if (o.list.length % 5 === 0) { %}5 list items{% } %}',
          data
        ).replace(/[\r\n]/g, '')
      ).to.equal('5 list items')