Module: Babl::Operators::Nav::DSL

Included in:
Template
Defined in:
lib/babl/operators/nav.rb

Instance Method Summary collapse

Instance Method Details

Navigate to a named property of the current element Multiple properties can be chained

A block can also be passed, but in that case, dependency tracking is disabled for the rest of the chain.



13
14
15
16
17
18
19
20
# File 'lib/babl/operators/nav.rb', line 13

def nav(*path, &block)
    if path.empty?
        return (block ? with(unscoped, &block) : construct_node(key: nil, continue: nil) { |node| node })
    end
    property = path.first.dup.freeze
    construct_node(key: nil, continue: nil) { |node| Nodes::Nav.new(property, node) }
        .nav(*path[1..-1], &block)
end