Sha256: 8a30a3f6c5beb22dd1fc02f1242a4c344de17048a287ea3dff4be494cb191cd7

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 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=\"#{File.join(app.config.assets.host, pack.public_path)}.js\"></script>\n")
                  end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pakyow-assets-1.0.0.rc5 lib/pakyow/assets/behavior/rendering/install_assets.rb
pakyow-assets-1.0.0.rc4 lib/pakyow/assets/behavior/rendering/install_assets.rb