mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-12-24 05:25 pm

[dw-free] Template Toolkit / Routing System

[commit: http://hg.dwscoalition.org/dw-free/rev/7391417900df]

http://bugs.dwscoalition.org/show_bug.cgi?id=2054

Remove unused helper functions. Add ability for templates to set extra
values.

Patch by [personal profile] exor674.

Files modified:
  • cgi-bin/DW/Routing/Apache2.pm
  • cgi-bin/DW/Template/Apache2.pm
  • views/error.tt
  • views/misc/pubkey.tt
  • views/misc/whereami.tt
--------------------------------------------------------------------------------
diff -r af9c31b2e8dd -r 7391417900df cgi-bin/DW/Routing/Apache2.pm
--- a/cgi-bin/DW/Routing/Apache2.pm	Thu Dec 24 07:26:51 2009 +0000
+++ b/cgi-bin/DW/Routing/Apache2.pm	Thu Dec 24 17:25:15 2009 +0000
@@ -300,32 +300,6 @@ sub register_regex {
 
 API to be used from the controllers.
 
-=head2 C<< $self->render_template( $template, $data, $extra ) >>
-
-Wrap stuff in the sitescheme.
-
-Helper so the controller doesn't need to dig out the Apache request.
-
-=cut
-
-sub render_template {
-    my $self = shift;
-    return DW::Template::Apache2->render_template( $self->{__r}, @_ );
-}
-
-=head2 C<< $self->render_cached_template( $key, $template, $subref, $extra ) >>
-
-Wrap stuff in the sitescheme.
-
-Helper so the controller doesn't need to dig out the Apache request.
-
-=cut
-
-sub render_cached_template {
-    my $self = shift;
-    return DW::Template::Apache2->render_cached_template( $self->{__r}, @_ );
-}
-
 =head2 C<< $self->args >>
 
 Return the arguments passed to the register call.
diff -r af9c31b2e8dd -r 7391417900df cgi-bin/DW/Template/Apache2.pm
--- a/cgi-bin/DW/Template/Apache2.pm	Thu Dec 24 07:26:51 2009 +0000
+++ b/cgi-bin/DW/Template/Apache2.pm	Thu Dec 24 17:25:15 2009 +0000
@@ -110,6 +110,8 @@ sub cached_template_string {
 sub cached_template_string {
     my ($class, $key, $filename, $subref, $opts, $extra ) = @_;
 
+    $extra ||= {};
+    $opts->{sections} = $extra;
     return DW::FragmentCache->get( $key, {
         lock_failed => $opts->{lock_failed},
         expire => $opts->{expire},
@@ -151,8 +153,6 @@ sub render_cached_template {
 sub render_cached_template {
     my ($class, $key, $filename, $subref, $opts, $extra) = @_;
 
-    $extra ||= {};
-
     my $out = $class->cached_template_string( $key, $filename, $subref, $opts, $extra );
 
     return $class->render_string( $out, $extra );
@@ -180,6 +180,9 @@ Render a template inside the sitescheme 
 
 sub render_template {
     my ( $class, $filename, $opts, $extra ) = @_;
+
+    $extra ||= {};
+    $opts->{sections} = $extra;
 
     my $out = $class->template_string( $filename, $opts );
 
diff -r af9c31b2e8dd -r 7391417900df views/error.tt
--- a/views/error.tt	Thu Dec 24 07:26:51 2009 +0000
+++ b/views/error.tt	Thu Dec 24 17:25:15 2009 +0000
@@ -1,3 +1,2 @@
-<h1>[% 'Error' | ml %]</h1>
-
+[%- sections.title = 'Error' | ml -%]
 <p><strong>[% message %]</strong></p>
diff -r af9c31b2e8dd -r 7391417900df views/misc/pubkey.tt
--- a/views/misc/pubkey.tt	Thu Dec 24 07:26:51 2009 +0000
+++ b/views/misc/pubkey.tt	Thu Dec 24 17:25:15 2009 +0000
@@ -1,5 +1,4 @@
-<h1>[% '.title' | ml %]</h1>
-
+[%- sections.title = '.title' | ml -%]
 [% IF u.public_key %]
     <p>[% '.label' | ml(user = u.ljuser_display) %]</p>
     <pre style='background-color:#efefef; border:3px solid #dedede; padding: 10px;'>
diff -r af9c31b2e8dd -r 7391417900df views/misc/whereami.tt
--- a/views/misc/whereami.tt	Thu Dec 24 07:26:51 2009 +0000
+++ b/views/misc/whereami.tt	Thu Dec 24 17:25:15 2009 +0000
@@ -1,5 +1,4 @@
-<h1>[% '.title' | ml %]</h1>
-
+[%- sections.title = '.title' | ml -%]
 <p>[% '.intro' | ml %]</p>
 
 <form action='[% roots.site %]/misc/whereami'>
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org