| ClearPress documentation | view source | Contained in the ClearPress distribution. |
ClearPress::view - MVC view superclass
$Revision: 388 $
my $oView = ClearPress::view::<subclass>->new({util => $oUtil});
$oView->model($oModel);
print $oView->decor()?
$oDecorator->header()
:
q(Content-type: ).$oView->content_type()."\n\n";
print $oView->render();
print $oView->decor()?$oDecorator->footer():q[];
View superclass for the ClearPress framework
my $oView = ClearPress::view::<subclass>->new({util => $oUtil, ...});
sets the aspect based on the HTTP Accept: header - useful for API access setting Accept: text/xml
my $sTemplateName = $oView->template_name();
my $sMethodName = $oView->method_name();
$oView->add_warning($sWarningMessage);
my $arWarningStrings = $oView->warnings();
my $sViewOutput = $oView->render();
Implemented in subclass:
sub streamed_aspects {
return [qw(list list_xml list_json)];
}
sub list { ... }
sub list_xml { ... }
sub list_json { ... }
$oView->create(); Populates $oSelf->model() with its expected parameters from the CGI block, then calls $oModel->create();
my $tt = $oView->tt();
sub init {
my $self = shift;
$self->add_tt_filter('foo_filter',
sub {
my $string = shift;
$string =~ s/foo/bar/smxg;
return $string;
});
return;
}
my $hrFilters = $oView->tt_filters();
$oView->util($oUtil); my $oUtil = $oView->util();
$oView->model($oModel); my $oModel = $oView->model();
$oView->action($sAction); my $sAction = $oView->action();
$oView->aspect($sAction); my $sAction = $oView->aspect();
$oView->content_type($sContentType); my $sContentType = $oView->content_type();
$oView->charset($sCharSet); my $sCharSet = $oView->charset();
$oView->decor($bDecorToggle); my $bDecorToggle = $oView->decor();
Usually set by the controller, after processing the request. Used for remapping requests to classes (specifically things of the form application::(model|view)::something::somethingelse . $oView->entity_name($sEntityName); my $sEntityName = $oView->entity_name();
my $sActionOutput = $oView->actions();
Process template.tt2 with standard parameters, output to stdout.
$oView->process_template('template.tt2');
Process template.tt2 with standard parameters plus extras, output to
stdout.
$oView->process_template('template.tt2', {extra=>'params'});
Process template.tt2 with standard plus extra parameters and output
into $to_scalar.
$oView->process_template('template.tt2', {extra=>'params'}, $to_scalar);
$oView->output_buffer(q[my string]); $oView->output_buffer(@aStrings);
$oView->output_end();
$oView->output_finished(1); $oViwe->output_finished(0);
$oView->output_flush();
$oView->output_reset();
If you're producing applications of moderate complexity, you almost
certainly want to disable autoescaping and handle it more cleverly
yourself. Subclass ClearPress::view and set self->autoescape to zero
or override the subroutine:
sub autoescape { return 0; }
Roger Pettett, <rpettett@cpan.org>
Copyright (C) 2008 Roger Pettett
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
| ClearPress documentation | view source | Contained in the ClearPress distribution. |