move constant delcarations into class {} block to make conversion cleaner
[catagits/Reaction.git] / lib / Reaction / UI / Widget.pm
index 0aab45e..3a9bc5c 100644 (file)
@@ -5,10 +5,11 @@ use aliased 'Reaction::UI::ViewPort';
 use aliased 'Reaction::UI::View';
 use aliased 'Reaction::UI::LayoutSet';
 
-sub DEBUG_FRAGMENTS () { $ENV{REACTION_UI_WIDGET_DEBUG_FRAGMENTS} }
-
 class Widget which {
 
+  sub DEBUG_FRAGMENTS () { $ENV{REACTION_UI_WIDGET_DEBUG_FRAGMENTS} }
+  sub DEBUG_LAYOUTS () { $ENV{REACTION_UI_WIDGET_DEBUG_LAYOUTS} }
+
   has 'view' => (isa => View, is => 'ro', required => 1);
   has 'layout_set' => (isa => LayoutSet, is => 'ro', required => 1);
   has 'fragment_names' => (is => 'ro', lazy_build => 1);
@@ -62,6 +63,11 @@ class Widget which {
                  || $layout_order[0][0]->isa($package)) {
             my $new_curr = [];
             my @l = @{shift(@layout_order)};
+            if (DEBUG_LAYOUTS) {
+              $self->view->app->log->debug(
+                "Layout ${fragment_name} in ${\$l[1]->name} from ${\$l[1]->source_file}"
+              );
+            }
             push(@$render_curr, [ -layout, $l[1], $fragment_name, $new_curr ]);
             push(@render_stack, $new_curr);
             push(@wclass_stack, $l[0]);
@@ -83,6 +89,11 @@ class Widget which {
     # if we had no fragment method or if we still have layouts left
     if (@layout_order) {
       while (my $l = shift(@layout_order)) {
+        if (DEBUG_LAYOUTS) {
+          $self->view->app->log->debug(
+            "Layout ${fragment_name} in ${\$l->[1]->name} from ${\$l->[1]->source_file}"
+          );
+        }
         push(@$render_deep, [
           -layout => $l->[1], $fragment_name, ($render_deep = [])
         ]);