Module: Babl::Operators::With::DSL

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

Instance Method Summary collapse

Instance Method Details

#with(*templates, &block) ⇒ Object

Produce a value by calling the block, passing it the output value of the templates passed as argument.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/babl/operators/with.rb', line 9

def with(*templates, &block)
    templates = templates.map { |t| unscoped.call(t) }

    construct_node(key: nil, continue: nil) do |node, context|
        Nodes::With.new(node, templates.map { |t|
            t.builder.precompile(
                Nodes::InternalValue.instance,
                context.merge(continue: nil)
            )
        }, block)
    end
end