+ # If no processing is requested then return the content.
+ if (!$options->{process}) {
+ # If $template is a reference then don't try to read a file.
+ my $ref = ref $template;
+ return $template if $ref eq 'SL::Presenter::EscapedText';
+ return SL::Presenter::EscapedText->new(text => ${ $template }, is_escaped => 1) if $ref eq 'SCALAR';
+
+ # Otherwise return the file's content.
+ my $file = IO::File->new($source, "r") || croak("Template file ${source} could not be read");
+ my $content = do { local $/ = ''; <$file> };
+ $file->close;
+
+ return SL::Presenter::EscapedText->new(text => $content, is_escaped => 1);
+ }
+
+ # Processing was requested. Set up all variables.