Sha256: a8634f27b1dd67b88ddcb85cc800265a29d2e90771a0c47a06a94dfcd5565bdd

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  module Presenter
    class Renderer
      module Behavior
        # @api private
        module SetPageTitle
          extend Support::Extension

          apply_extension do
            attach do |presenter|
              presenter.render node: -> {
                if title_value = info(:title)
                  title.object.set_label(:title_template, title_value); title
                end
              } do
                self.html = html_safe(
                  Support::StringBuilder.new(object.label(:title_template), html_safe: true) { |object_value|
                    if respond_to?(object_value)
                      send(object_value, :title) || send(object_value)
                    elsif @presentables.key?(object_value)
                      @presentables[object_value]
                    else
                      nil
                    end
                  }.build
                )
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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