[dw-free] Expose create_url in the TT plugin
[commit: http://hg.dwscoalition.org/dw-free/rev/3b443196fc5d]
http://bugs.dwscoalition.org/show_bug.cgi?id=3237
Add a dw.create_url Template Toolkit method.
Patch by
exor674.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3237
Add a dw.create_url Template Toolkit method.
Patch by
Files modified:
- cgi-bin/DW/Template/Plugin.pm
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
