# Code coverage report for lib/template/component.js

## Statements: 100% (13 / 13) Branches: 100% (0 / 0) Functions: 100% (5 / 5) Lines: 100% (13 / 13) Ignored: none

All files » lib/template/ » component.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
    271

    1
    7

    1

    7
    7
    7
    7

    8
    8
    8

    2

    3

     var BaseComponent    = require("../components/base"),
    _bind                = require("../utils/bind"),
    ScopedBindableObject = require("scoped-bindable-object");

    function TemplateComponent (options) {
      BaseComponent.call(this, options);
    }

    module.exports = BaseComponent.extend(TemplateComponent, {
      initialize: function () {
        this.view = this.template.view();
        this.section.appendChild(this.view.render());
        this.context = new ScopedBindableObject(this.attributes.toJSON());
        this.attributes.on("change", _bind(this._onAttrsChange, this));
      },
      bind: function (context) {
        this.context.set("parent", context);
        this.view.bind(this.context);
        BaseComponent.prototype.bind.call(this, this.context);
      },
      unbind: function () {
        this.view.unbind();
      },
      _onAttrsChange: function (key, value) {
        this.context.set(key, value);
      }
    });