Sha256: bcbc7712f4645c0cba1794a9ce5fd959ef9a04a3b983a15034c4d3d9e812ed7a

Contents?: true

Size: 1.37 KB

Versions: 19

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'phlex/rails'

# Include this in your view for additional logic for rendering a full HTML page, usually from a
# controller.
module Proscenium::Phlex::Page
  include Phlex::Rails::Helpers::CSPMetaTag
  include Phlex::Rails::Helpers::CSRFMetaTags
  include Phlex::Rails::Helpers::FaviconLinkTag
  include Phlex::Rails::Helpers::PreloadLinkTag
  include Phlex::Rails::Helpers::StyleSheetLinkTag
  include Phlex::Rails::Helpers::ActionCableMetaTag
  include Phlex::Rails::Helpers::AutoDiscoveryLinkTag
  include Phlex::Rails::Helpers::JavaScriptIncludeTag
  include Phlex::Rails::Helpers::JavaScriptImportMapTags
  include Phlex::Rails::Helpers::JavaScriptImportModuleTag

  def self.included(klass)
    klass.extend(Phlex::Rails::Layout::Interface)
  end

  def template(&block)
    doctype
    html do
      head
      body(&block)
    end
  end

  private

  def after_template
    super
    @_buffer.gsub!('<!-- [SIDE_LOAD_STYLESHEETS] -->', capture { side_load_stylesheets })
  end

  def page_title
    Rails.application.class.name.deconstantize
  end

  def head
    super do
      title { page_title }

      yield if block_given?

      csp_meta_tag
      csrf_meta_tags

      comment { '[SIDE_LOAD_STYLESHEETS]' }
    end
  end

  def body
    super do
      yield if block_given?

      side_load_javascripts defer: true, type: :module
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
proscenium-0.9.1-x86_64-linux lib/proscenium/phlex/page.rb
proscenium-0.9.1-aarch64-linux lib/proscenium/phlex/page.rb
proscenium-0.9.1-arm64-darwin lib/proscenium/phlex/page.rb
proscenium-0.9.1-x86_64-darwin lib/proscenium/phlex/page.rb
proscenium-0.9.0-x86_64-linux lib/proscenium/phlex/page.rb
proscenium-0.9.0-aarch64-linux lib/proscenium/phlex/page.rb
proscenium-0.9.0-arm64-darwin lib/proscenium/phlex/page.rb
proscenium-0.9.0-x86_64-darwin lib/proscenium/phlex/page.rb
proscenium-0.8.2-x86_64-linux lib/proscenium/phlex/page.rb
proscenium-0.8.2-aarch64-linux lib/proscenium/phlex/page.rb
proscenium-0.8.2-arm64-darwin lib/proscenium/phlex/page.rb
proscenium-0.8.2-x86_64-darwin lib/proscenium/phlex/page.rb
proscenium-0.8.0-aarch64-linux lib/proscenium/phlex/page.rb
proscenium-0.8.0-arm64-darwin lib/proscenium/phlex/page.rb
proscenium-0.8.0-x86_64-darwin lib/proscenium/phlex/page.rb
proscenium-0.7.0-x86_64-linux lib/proscenium/phlex/page.rb
proscenium-0.7.0-aarch64-linux lib/proscenium/phlex/page.rb
proscenium-0.7.0-arm64-darwin lib/proscenium/phlex/page.rb
proscenium-0.7.0-x86_64-darwin lib/proscenium/phlex/page.rb