lib/pakyow/presenter/behavior/initializing.rb in pakyow-presenter-1.0.0.rc1 vs lib/pakyow/presenter/behavior/initializing.rb in pakyow-presenter-1.0.0.rc2
- old
+ new
@@ -10,25 +10,55 @@
module Initializing
extend Support::Extension
apply_extension do
unless ancestors.include?(Plugin)
- after "load", "load.presenter" do
+ after "initialize", "initialize.presenter", priority: :high do
state(:templates) << Templates.new(
:default,
config.presenter.path,
processor: ProcessorCaller.new(
- state(:processor)
+ state(:processor).map { |processor|
+ processor.new(self)
+ }
)
)
state(:templates) << Templates.new(:errors, File.join(File.expand_path("../../../", __FILE__), "views", "errors"))
end
after "load.plugins" do
# Load plugin frontend after the app so that app has priority.
#
@plugs.each(&:load_frontend)
+ end
+ end
+
+ # Build presenter classes for compound components.
+ #
+ after "initialize", priority: :high do
+ state(:templates).each do |templates|
+ templates.each do |template|
+ template.object.each_significant_node(:component, descend: true) do |node|
+ if node.label(:components).count > 1
+ component_classes = node.label(:components).each_with_object([]) { |component_label, arr|
+ component_class = state(:component).find { |component|
+ component.__object_name.name == component_label[:name]
+ }
+
+ if component_class
+ arr << component_class
+ end
+ }
+
+ if component_classes.count > 1
+ state(:presenter) << Actions::RenderComponents.find_or_build_compound_presenter(
+ self, component_classes
+ )
+ end
+ end
+ end
+ end
end
end
end
end
end