# Code coverage report for lib/parser/index.js

## Statements: 100% (15 / 15) Branches: 83.33% (5 / 6) Functions: 100% (2 / 2) Lines: 100% (15 / 15) Ignored: 2 statements, 1 branch

All files » lib/parser/ » index.js

    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
    421
    1
    1

    1

    97

    222

    222
    53

    169
    169

    169

    169

    1
    1
    1

     var parser  = require("./parser");
    var scripts = {};
    var parse;

    /**
     */

    module.exports = {

      /**
       */

      parse: parse = function(html) {
        return "\"use strict\";module.exports = " + parser.parse(html).toJavaScript();
      },

      /**
       */

      compile: function(nameOrContent) {
        var content;

        if (scripts[nameOrContent]) {
          return scripts[nameOrContent];
        }

        Eif (!content) {
          content = nameOrContent;
        }

        var source = "\"use strict\";return " + parser.parse(content).toJavaScript();

        return (scripts[nameOrContent] = new Function(source)());
      }
    };

    /* istanbul ignore if */
    Iif (global.paperclip) {
      global.paperclip.parse           = module.exports.parse;
      global.paperclip.template.parser = module.exports;
    }