aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/LayoutSet
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-09-12 18:11:34 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-09-12 18:11:34 +0000
commit7adfd53f17f66ffe93763e944ed1d3fc52a369dc (patch)
tree19e599e74419b41cbbe651fd226b81e8b73551d3 /lib/Reaction/UI/LayoutSet
parentc728c97cb1061330e63c7cc048e768ef74988fe6 (diff)
downloadreaction-7adfd53f17f66ffe93763e944ed1d3fc52a369dc.tar.gz
reaction-7adfd53f17f66ffe93763e944ed1d3fc52a369dc.zip
moved shit to trunk
Diffstat (limited to 'lib/Reaction/UI/LayoutSet')
-rw-r--r--lib/Reaction/UI/LayoutSet/TT.pm44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/Reaction/UI/LayoutSet/TT.pm b/lib/Reaction/UI/LayoutSet/TT.pm
new file mode 100644
index 0000000..72d3fad
--- /dev/null
+++ b/lib/Reaction/UI/LayoutSet/TT.pm
@@ -0,0 +1,44 @@
+package Reaction::UI::LayoutSet::TT;
+
+use Reaction::Class;
+use aliased 'Reaction::UI::LayoutSet';
+use aliased 'Template::View';
+
+class TT is LayoutSet, which {
+
+ has 'tt_view' => (is => 'rw', isa => View, lazy_fail => 1);
+
+ implements 'BUILD' => as {
+ my ($self, $args) = @_;
+
+ # Do this at build time rather than on demand so any exception if it
+ # goes wrong gets thrown sometime sensible
+
+ $self->tt_view($self->_build_tt_view($args));
+ };
+
+ implements '_build_tt_view' => as {
+ my ($self, $args) = @_;
+ my $tt_object = $args->{tt_object}
+ || confess "tt_object not provided to new()";
+ my $tt_args = { data => {} };
+ my $name = $self->name;
+ my $fragments = $self->fragments;
+ my $tt_source = qq{[% VIEW ${name};\n\n}.
+ join("\n\n",
+ map {
+ qq{BLOCK $_; -%]\n}.$fragments->{$_}.qq{\n[% END;};
+ } keys %$fragments
+ ).qq{\nEND; # End view\ndata.view = ${name};\n %]};
+ $tt_object->process(\$tt_source, $tt_args)
+ || confess "Template processing error: ".$tt_object->error
+ ." processing:\n${tt_source}";
+ confess "View template processed but no view object found"
+ ." after processing:\n${tt_source}"
+ unless $tt_args->{data}{view};
+ return $tt_args->{data}{view};
+ };
+
+};
+
+1;