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.reset_continue.call(t) }

    construct_node { |node, context|
        Nodes::With.new(node, templates.map { |t|
            t.builder.precompile(
                Nodes::InternalValue.instance,
                context
            )
        }, block)
    }.reset_key.reset_continue
end