Exemple #1
0
// Render returns the groups markup for the giving render group.
func (v *view) Render() *trees.Markup {
	defer v.rendered.Publish()

	v.renderedBefore = true

	if len(v.renders) == 0 {
		return trees.NewMarkup(v.tag, false)
	}

	var root *trees.Markup

	if len(v.renders) > 1 {
		root = trees.NewMarkup(v.tag, false)

		for _, view := range v.renders {
			view.Render().Apply(root)
		}

	} else {
		root = v.renders[0].Render()
	}

	if v.live != nil {
		live := v.live
		live.EachEvent(func(e *trees.Event, _ *trees.Markup) {
			if e.Handle != nil {
				e.Handle.End()
			}
		})

		v.live = nil
		root.Reconcile(live)

		// Clear out internal references with the current live markup.
		// TODO: Check if this will cause unknown side effects.
		if live != root {
			live.Empty()
		}
	}

	root.SwapUID(v.uuid)
	root = root.ApplyMorphers()

	v.live = root

	return root
}
Exemple #2
0
// Apply adds this routing as a morpher into the provided markup.
func (r *routing) Apply(mr *trees.Markup) {
	mr.AddMorpher(r)
}