Sha256: 2a4db56b7c061fb3b353ef3b3dd607e80fec520add0b966b72f220d05308f550

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  module Presenter
    class Renderer
      module Behavior
        module CleanupUnboundBindings
          extend Support::Extension

          apply_extension do
            attach do |presenter|
              unless Pakyow.env?(:prototype)
                # Cleanup unbound bindings. We don't do this in prototype mode because it's important
                # for the prototype to be complete, showing everything to the designer.
                #
                presenter.render node: -> {
                  object.find_significant_nodes(:binding, descend: true).map { |node|
                    View.from_object(node)
                  }
                }, priority: :low do
                  # We check that the node is still labeled as a binding in case the node was replaced
                  # during a previous transformation with a node that isn't a binding.
                  #
                  unless !view.object.labeled?(:binding) || view.object.labeled?(:bound) || view.object.labeled?(:failed) || view.object.label(:version) == :empty
                    remove
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pakyow-presenter-1.0.1 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.0 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.0.rc5 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.0.rc4 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.0.rc3 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb