Sha256: 42719547e043a4760679b619d0652723a35cafc1670bd5d159edc630114b8c7d

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  module Presenter
    class Renderer
      module Behavior
        module Assets
          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.top.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.top.config.assets.host, pack.public_path)}.css\">\n")
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pakyow-assets-1.0.6 lib/pakyow/presenter/renderer/behavior/assets/install_assets.rb
pakyow-assets-1.0.5 lib/pakyow/presenter/renderer/behavior/assets/install_assets.rb
pakyow-assets-1.0.4 lib/pakyow/presenter/renderer/behavior/assets/install_assets.rb
pakyow-assets-1.0.3 lib/pakyow/presenter/renderer/behavior/assets/install_assets.rb
pakyow-assets-1.0.2 lib/pakyow/presenter/renderer/behavior/assets/install_assets.rb