Sha256: 0ebf0775a670b8d545190481ef5da1296ff2c70f43869a87801fbc348a21399f

Contents?: true

Size: 593 Bytes

Versions: 3

Compression:

Stored size: 593 Bytes

Contents

# frozen_string_literal: true

module Exclaim
  module Implementations
    LET_COMPONENT = ->(config, _env, &render_child) do
      bindings = (config['bindings'] || config['$let']).to_h
      child_component = config['do']

      # This implementation passes only the configured bindings as the env for
      # the child component. As an alternative approach, it could merge the bindings
      # onto the parent env to make all values available to the child.
      render_child.call(child_component, bindings)
    end
    LET_COMPONENT.define_singleton_method(:component?) { true }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-exclaim-0.1.1 lib/exclaim/implementations/let_component.rb
ruby-exclaim-0.1.0 lib/exclaim/implementations/let_component.rb
ruby-exclaim-0.0.0 lib/exclaim/implementations/let_component.rb