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

## Statements: 46.67% (7 / 15) Branches: 33.33% (2 / 6) Functions: 0% (0 / 2) Lines: 46.67% (7 / 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

    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];
        }

        if (!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;
    }