Sha256: 45a4fd92fb74fdf3238ac7d941df6f7d99e4835f0e5fe8181c3ec762c717accc

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  module Assets
    module Behavior
      module Rendering
        module InstallAssets
          extend Support::Extension

          apply_extension do
            build do |view, app:|
              if head = view.head
                packs = app.packs(view)

                if app.is_a?(Plugin)
                  packs = app.parent.packs(view).concat(packs)
                end

                packs.uniq { |pack|
                  pack.public_path
                }.each do |pack|
                  if pack.javascripts?
                    head.object.append_html("<script src=\"#{pack.public_path}.js\"></script>\n")
                  end

                  if pack.stylesheets?
                    head.object.append_html("<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"#{pack.public_path}.css\">\n")
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pakyow-assets-1.0.0.rc3 lib/pakyow/assets/behavior/rendering/install_assets.rb
pakyow-assets-1.0.0.rc2 lib/pakyow/assets/behavior/rendering/install_assets.rb
pakyow-assets-1.0.0.rc1 lib/pakyow/assets/behavior/rendering/install_assets.rb