UNPKG

silk-gui

Version:

GUI for developers and Node OS

50 lines (43 loc) 1.19 kB
var _ = require('../util') var templateParser = require('../parsers/template') var vIf = require('./if') module.exports = { isLiteral: true, // same logic reuse from v-if compile: vIf.compile, teardown: vIf.teardown, getContainedComponents: vIf.getContainedComponents, unbind: vIf.unbind, bind: function () { var el = this.el this.start = document.createComment('v-partial-start') this.end = document.createComment('v-partial-end') if (el.nodeType !== 8) { el.innerHTML = '' } if (el.tagName === 'TEMPLATE' || el.nodeType === 8) { _.replace(el, this.end) } else { el.appendChild(this.end) } _.before(this.start, this.end) if (!this._isDynamicLiteral) { this.insert(this.expression) } }, update: function (id) { this.teardown() this.insert(id) }, insert: function (id) { var partial = this.vm.$options.partials[id] _.assertAsset(partial, 'partial', id) if (partial) { var filters = this.filters && this.filters.read if (filters) { partial = _.applyFilters(partial, filters, this.vm) } this.compile(templateParser.parse(partial, true)) } } }