lib/dry/view/layout.rb in dry-view-0.1.0 vs lib/dry/view/layout.rb in dry-view-0.1.1
- old
+ new
@@ -10,12 +10,10 @@
module Dry
module View
class Layout
include Dry::Equalizer(:config)
- Scope = Struct.new(:page)
-
DEFAULT_DIR = 'layouts'.freeze
extend Dry::Configurable
setting :root
@@ -57,12 +55,14 @@
end
def call(options = {})
renderer = self.class.renderer(options.fetch(:format, default_format))
+ template_content = renderer.(template_path, template_scope(options, renderer))
+
renderer.(layout_path, layout_scope(options, renderer)) do
- renderer.(template_path, template_scope(options, renderer))
+ template_content
end
end
def locals(options)
options.fetch(:locals, {})
@@ -92,10 +92,14 @@
end
private
def layout_scope(options, renderer)
- Scope.new(layout_part(:page, renderer, options.fetch(:scope, scope)))
+ part_hash = {
+ page: layout_part(:page, renderer, options.fetch(:scope, scope))
+ }
+
+ part(layout_dir, renderer, part_hash)
end
def template_scope(options, renderer)
parts(locals(options), renderer)
end