Sha256: 42f164a3dfc0478b7f2c67ce68385c17320791691e9377ad1f311758f9726cc4

Contents?: true

Size: 848 Bytes

Versions: 10

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module Pakyow
  module Presenter
    module Views
      class Layout < View
        attr_accessor :name

        class << self
          def load(path, content: nil, **args)
            self.new(File.basename(path, ".*").to_sym, content || File.read(path), **args)
          end
        end

        def initialize(name, html = "", **args)
          @name = name
          super(html, **args)
        end

        def container(name = Views::Page::DEFAULT_CONTAINER)
          @object.container(name.to_sym)
        end

        def build(page)
          @object.each_significant_node(:container) do |container_node|
            container_node.replace(page.content(container_node.label(:container)))
          end

          View.from_object(@object).add_info(info, page.info)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pakyow-presenter-1.0.6 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.5 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.4 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.3 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.2 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.1 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.0 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.0.rc5 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.0.rc4 lib/pakyow/presenter/views/layout.rb
pakyow-presenter-1.0.0.rc3 lib/pakyow/presenter/views/layout.rb