1 package Reaction::UI::Renderer::XHTML;
4 use base qw/Catalyst::View::TT Reaction::Object/;
10 CATALYST_VAR => 'ctx',
15 my ($self, $window) = @_;
16 my $root_vp = $window->focus_stack->vp_head;
17 confess "Can't flush view for window with empty focus stack"
18 unless defined($root_vp);
19 $self->render_viewport($window, $root_vp);
23 my ($self, $window, $vp) = @_;
24 my $ctx = $window->ctx;
31 unless (length $args{type}) {
32 my $type = (split('::', ref($vp)))[-1];
33 $args{type} = lc($type);
35 return $self->render($ctx, 'component', \%args);
38 around 'render' => sub {
40 my ($self,$args) = @_[0,3];
41 local $self->template->{SERVICE}{CONTEXT}{BLKSTACK};
42 local $self->template->{SERVICE}{CONTEXT}{BLOCKS};
43 $args->{process_attrs} = \&process_attrs;
49 return $attrs unless ref $attrs eq 'HASH';
52 while( my($k,$v) = each(%$attrs) ){
54 next if ($enc_v eq "");
55 if ($k eq 'class' && ref $v eq 'ARRAY'){
56 $enc_v = join ' ', map { encode_entities($_) } @$v;
57 } elsif ($k eq 'style' && ref $v eq 'HASH'){
58 $enc_v = join '; ', map{ "${_}: ".encode_entities($v->{$_}) } keys %{$v};
60 push(@processed_attrs, "${k}=\"${enc_v}\"");
63 return ' '.join ' ', @processed_attrs if (scalar(@processed_attrs) > 0);
71 Reaction::UI::Renderer::XHTML
83 See L<Reaction::Class> for authors.
87 See L<Reaction::Class> for the license.