Sha256: 04fa19454d8faa403f5c0b23c3eb53325fb232a0042f6777ce8eba319cdc6f6b

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

require "pakyow/presenter/view"

module Pakyow
  module Presenter
    class Renderer
      module Behavior
        module UI
          module InstallTransforms
            extend Support::Extension

            apply_extension do
              attach do |presenter|
                presenter.render node: -> {
                  nodes = []

                  if html_node = object.find_first_significant_node(:html)
                    nodes << Pakyow::Presenter::View.from_object(html_node)
                  end

                  if !object.is_a?(StringDoc) && object.significant?(:component)
                    nodes << Pakyow::Presenter::View.from_object(object)
                  end

                  object.each_significant_node_without_descending_into_type(:component, descend: true) do |node|
                    if node.label(:components).any? { |c| c[:renderable ] }
                      nodes << Pakyow::Presenter::View.from_object(node)
                    end
                  end

                  nodes
                } do
                  if transformation_id = presentables[:__transformation_id]
                    # Set the transformation_id on the target node so that transformations can be applied to the right place.
                    #
                    attributes[:"data-t"] = transformation_id
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pakyow-ui-1.0.6 lib/pakyow/presenter/renderer/behavior/ui/install_transforms.rb
pakyow-ui-1.0.5 lib/pakyow/presenter/renderer/behavior/ui/install_transforms.rb
pakyow-ui-1.0.4 lib/pakyow/presenter/renderer/behavior/ui/install_transforms.rb
pakyow-ui-1.0.3 lib/pakyow/presenter/renderer/behavior/ui/install_transforms.rb
pakyow-ui-1.0.2 lib/pakyow/presenter/renderer/behavior/ui/install_transforms.rb
pakyow-ui-1.0.1 lib/pakyow/presenter/renderer/behavior/ui/install_transforms.rb
pakyow-ui-1.0.0 lib/pakyow/presenter/renderer/behavior/ui/install_transforms.rb