Sha256: 8fc9438e0a5e551621d5bce69b933cd17a7e1daac0d9dac6e595b47fe009f273

Contents?: true

Size: 889 Bytes

Versions: 5

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  module Presenter
    class Renderer
      module Behavior
        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.1 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.0 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.0.rc5 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.0.rc4 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb
pakyow-presenter-1.0.0.rc3 lib/pakyow/presenter/renderer/behavior/create_template_nodes.rb