{"size": 2957, "ext": "js", "max_stars_repo_path": "lib/compiler/tokens/tag.js", "max_stars_repo_name": "Mike96Angelo/Bars", "max_stars_repo_stars_event_min_datetime": "2016-09-27T21:20:37.000Z", "max_stars_repo_stars_event_max_datetime": "2017-01-13T17:08:59.000Z", "max_issues_repo_path": "lib/compiler/tokens/tag.js", "max_issues_repo_name": "Mike96Angelo/Bars", "max_issues_repo_issues_event_min_datetime": "2016-11-14T01:49:48.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-31T17:36:54.000Z", "max_forks_repo_path": "lib/compiler/tokens/tag.js", "max_forks_repo_name": "Mike96Angelo/Bars", "max_forks_repo_forks_event_min_datetime": "2015-11-30T14:14:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-27T17:22:35.000Z"}
{"max_stars_count": 6, "max_issues_count": 8, "max_forks_count": 4, "avg_line_length": 20.2534246575, "max_line_length": 69, "alphanum_fraction": 0.426445722}
var Token = require('./token');

var TagToken = Token.generate(
    function TagToken(code) {
        var _ = this;

        if (code) {
            Token.call(_, code);
        }

        _.name = '';

        _.attrs = [];
        _.props = [];
        _.binds = [];
        _.nodes = [];

        _.attrsUpdate = 0;
        _.nodesUpdate = 0;
    }
);


TagToken.definePrototype({
    enumerable: true
}, {
    type: 'tag'
});

TagToken.definePrototype({
    TYPE_ID: Token.tokens.push(TagToken) - 1,
    toArray: function () {
        var _ = this;
        return [
            _.TYPE_ID,
            _.name,
            _.attrs,
            _.attrsUpdate,
            _.nodes,
            _.nodesUpdate,
            _.props,
            _.binds
        ];
    },

    toObject: function () {
        var _ = this;
        return {
            type: _.type,
            TYPE_ID: _.TYPE_ID,
            name: _.name,
            attrs: _.attrs,
            attrsUpdate: _.attrsUpdate,
            nodes: _.nodes,
            nodesUpdate: _.nodesUpdate,
            props: _.props,
            binds: _.binds
        };
    },

    _fromArray: function _fromArray(arr) {
        var _ = this;

        _.name = arr[1];

        _.attrs = arr[2].map(function (item) {
            var attr = new Token.tokens[item[0]]();

            attr.fromArray(item);

            return attr;
        });

        _.attrsUpdate = arr[3];

        _.nodes = arr[4].map(function (item) {
            var node = new Token.tokens[item[0]]();

            node.fromArray(item);

            return node;
        });

        _.nodesUpdate = arr[5];

        _.props = arr[6].map(function (item) {
            var prop = new Token.tokens[item[0]]();

            prop.fromArray(item);

            return prop;
        });

        _.binds = arr[7].map(function (item) {
            var bind = new Token.tokens[item[0]]();

            bind.fromArray(item);

            return bind;
        });
    },

    toString: function toString() {
        var _ = this,
            str = _.indentLevel + '<' + _.name;

        for (var i = 0; i < _.attrs.length; i++) {
            str += _.attrs[i].toString();
        }

        if (_.selfClosed) {
            str += (_.attrs.length ? ' ' : '') + '/>'; 
            return str;
        }

        str += '>'; 
        if (_.selfClosing) {
            return str;
        }
        var nodes = '';
        for (i = 0; i < _.nodes.length; i++) {
            _.nodes[i].indentLevel = (_.indentLevel ? _.indentLevel +
                '  ' : '');
            nodes += _.nodes[i].toString();
        }

        str += nodes.trim();

        str += _.indentLevel + '</' + _.name + '>';

        return str;
    },

    updates: function updates(type) {
        var _ = this;

        if (type === 'attr') {
            _.attrsUpdate = 1;
        } else {
            _.nodesUpdate = 1;
        }
    }
});

Token.tokens.tag = TagToken;
