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

## Statements: 85.71% (12 / 14) Branches: 66.67% (4 / 6) Functions: 50% (1 / 2) Lines: 85.71% (12 / 14) Ignored: none

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

    168

    168
    32

    136
    136

    136
    136

    136

    136

     var parser = require("./parser");

    var scripts = {}, 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];
        }

        try {
          Iif (typeof $ !== "undefined") {
            content = $("script[data-template-name='" + nameOrContent + "']").html();
          }
        } catch (e) {

        }

        Eif (!content) {
          content = nameOrContent;
        }

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

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