# Code coverage report for lib/template/vnode/block/index.js

## Statements: 100% (15 / 15) Branches: 50% (1 / 2) Functions: 100% (3 / 3) Lines: 100% (15 / 15) Ignored: none

All files » lib/template/vnode/block/ » 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
    371
    1
    1
    1
    1
    1

    1
    3

    1

    3
    3
    3
    3

    1
    3

     var protoclass = require("protoclass");
    var utils      = require("../../../utils");
    var script     = require("../../../script");
    var Hydrator   = require("./hydrator");
    var Binding    = require("./binding");
    var Unbound    = require("./unbound");

    /**
     */

    function Block(scriptSource) {
      this.script  = script(scriptSource);
    }

    /**
     */

    module.exports = protoclass(Block, {

      /**
       */

      initialize: function(template) {
        var node = template.document.createTextNode("");
        var bindingClass = this.script.refs.length ? Binding : Unbound;
        template.hydrators.push(new Hydrator(node, this.script, bindingClass));
        return node;
      }
    });

    /**
     */

    module.exports.create = function(script) {
      return new Block(script);
    };