Sha256: 051fc281179fc3980ee0a41aa1e2a885146a039e8f399368680378891d7c900f

Contents?: true

Size: 912 Bytes

Versions: 5

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  module Presenter
    class Renderer
      module Behavior
        # @api private
        module CreateTemplateNodes
          extend Support::Extension

          apply_extension do
            build do |view|
              unless Pakyow.env?(:prototype)
                view.each_binding_scope(descend: true) do |node_with_binding|
                  attributes = node_with_binding.attributes.attributes_hash.each_with_object({}) do |(attribute, value), acc|
                    acc[attribute] = value if attribute.to_s.start_with?("data")
                  end

                  node_with_binding.after("<script type=\"text/template\"#{StringDoc::Attributes.new(attributes).to_s}>#{node_with_binding.render}</script>")
                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.6 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.5 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.4 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.3 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.2 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb