Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 287e81e0

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 287e81e0c99c7e203b9c78bcd6a1cf1a7c28d6f6
  • Vorgänger 36a33b59
  • Nachfolger ea974a5a

render() in Controller+Presenter: Support für Typ "text"

Unterschiede anzeigen:

SL/Presenter.pm
40 40
  }
41 41

  
42 42
  # Only certain types are supported.
43
  croak "Unsupported type: " . $options->{type} unless $options->{type} =~ m/^(?:html|js|json)$/;
43
  croak "Unsupported type: " . $options->{type} unless $options->{type} =~ m/^(?:html|js|json|text)$/;
44 44

  
45 45
  # The "template" argument must be a string or a reference to one.
46 46
  $template = ${ $template }                                       if ((ref($template) || '') eq 'REF') && (ref(${ $template }) eq 'SL::Presenter::EscapedText');
......
49 49
  # Look for the file given by $template if $template is not a reference.
50 50
  my $source;
51 51
  if (!ref $template) {
52
    $source = "templates/webpages/${template}." . $options->{type};
52
    my $ext = $options->{type} eq 'text' ? 'txt' : $options->{type};
53
    $source = "templates/webpages/${template}.${ext}";
53 54
    croak "Template file ${source} not found" unless -f $source;
54 55

  
55 56
  } elsif (ref($template) eq 'SCALAR') {
......
223 224

  
224 225
=item C<type>
225 226

  
226
The template type. Can be C<html> (the default), C<js> for JavaScript
227
or C<json> for JSON content. Affects only the extension that's added
228
to the file name given with a non-reference C<$template> argument.
227
The template type. Can be C<html> (the default), C<js> for JavaScript,
228
C<json> for JSON and C<text> for plain text content. Affects only the
229
extension that's added to the file name given with a non-reference
230
C<$template> argument.
229 231

  
230 232
=item C<process>
231 233

  

Auch abrufbar als: Unified diff