3 // EvalNodeFilterFunc is the callback used to replace a node with
4 // another to node. To not do the replacement, just return the input node.
5 type EvalNodeFilterFunc func(EvalNode) EvalNode
7 // EvalNodeFilterable is an interface that can be implemented by
8 // EvalNodes to allow filtering of sub-elements. Note that this isn't
9 // a common thing to implement and you probably don't need it.
10 type EvalNodeFilterable interface {
12 Filter(EvalNodeFilterFunc)
15 // EvalFilter runs the filter on the given node and returns the
16 // final filtered value. This should be called rather than checking
17 // the EvalNode directly since this will properly handle EvalNodeFilterables.
18 func EvalFilter(node EvalNode, fn EvalNodeFilterFunc) EvalNode {
19 if f, ok := node.(EvalNodeFilterable); ok {