Add a dw.create_url Template Toolkit method.

        Patch by exor674. 

diffs (43 lines):

diff -r daca6070e1a4 -r 3b443196fc5d cgi-bin/DW/Template/Plugin.pm
--- a/cgi-bin/DW/Template/Plugin.pm     Sun Jan 16 20:45:02 2011 -0600
+++ b/cgi-bin/DW/Template/Plugin.pm     Sun Jan 16 22:16:51 2011 -0600
@@ -105,24 +105,16 @@ sub form_auth {
     return LJ::form_auth();
 }
 
-=head2 sort_by_key
+=head2 create_url
 
-Sorts an array of hashrefs by given key
+Wrapper around LJ::create_url
+
+    [% dw.create_url( undef, keep_args => 1 ) %]
 
 =cut
 
-sub sort_by_key {
-    my $k = $_[2];
-    my $md = $_[3] || 'alpha';
-
-    my @r;
-    if ( $md eq 'alpha' ) {
-        @r = sort { $a->{$k} cmp $b->{$k} } @{$_[1]};
-    } else {
-        @r = sort { $a->{$k} <=> $b->{$k} } @{$_[1]};
-    }
-
-    return \@r;
+sub create_url {
+    return LJ::create_url( $_[1], %{ $_[2] || {} } );
 }
 
 =head1 AUTHOR
@@ -137,7 +129,7 @@ sub sort_by_key {
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2010 by Dreamwidth Studios, LLC.
+Copyright (c) 2010-2011 by Dreamwidth Studios, LLC.
 
 This program is free software; you may redistribute it and/or modify it under
 the same terms as Perl itself. For a copy of the license, please reference
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to