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.



10
11
12
13
14
15
16
# File 'lib/babl/operators/nav.rb', line 10

def nav(*path, &block)
    if path.empty?
        return (block ? with(unscoped, &block) : construct_node(key: nil, continue: nil) { |node| node })
    end

    construct_node(key: nil, continue: nil) { |node| NavNode.new(path.first, node) }.nav(*path[1..-1], &block)
end