[dw-free] Add ML scope getter to DW::Template::Plugin
[commit: http://hg.dwscoalition.org/dw-free/rev/190d8daebf5d]
http://bugs.dwscoalition.org/show_bug.cgi?id=2469
Allow retrieving ML scope in Template Toolkit. (For determining where to
look up the translation strings from). Comment cleanup.
Patch by
pauamma.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2469
Allow retrieving ML scope in Template Toolkit. (For determining where to
look up the translation strings from). Comment cleanup.
Patch by
Files modified:
- cgi-bin/DW/Template/Filters.pm
- cgi-bin/DW/Template/Plugin.pm
--------------------------------------------------------------------------------
diff -r 6729614a1222 -r 190d8daebf5d cgi-bin/DW/Template/Filters.pm
--- a/cgi-bin/DW/Template/Filters.pm Tue Apr 13 03:50:38 2010 -0700
+++ b/cgi-bin/DW/Template/Filters.pm Tue Apr 13 04:31:40 2010 -0700
@@ -17,7 +17,23 @@ package DW::Template::Filters;
package DW::Template::Filters;
use strict;
-# Seperated out of DW::Template::Plugin to avoid accidental use as a method.
+=head1 NAME
+
+DW::Template::Plugin - Template Toolkit plugin for Dreamwidth
+
+=head1 METHODS
+
+=cut
+
+=head2 ml
+
+Apply a ML string.
+
+ [% '.foo' | ml(arg = 'bar') %]
+
+=cut
+
+# Separated out of DW::Template::Plugin to avoid accidental use as a method.
sub ml {
# save the last argument as the hashref, hopefully
my $args = $_[-1];
diff -r 6729614a1222 -r 190d8daebf5d cgi-bin/DW/Template/Plugin.pm
--- a/cgi-bin/DW/Template/Plugin.pm Tue Apr 13 03:50:38 2010 -0700
+++ b/cgi-bin/DW/Template/Plugin.pm Tue Apr 13 04:31:40 2010 -0700
@@ -60,25 +60,21 @@ sub need_res {
=head2 ml_scope
-Set the ML scope of the template
+Get or set the ML scope of the template
- [% dw.ml_scope( '/foo.tt' ) %]
+ # store the old value
+ [% old_scope = dw.ml_scope( ) %]
+
+ # CALL forces us to ignore the returned value, and not print it out
+ [% CALL dw.ml_scope( '/foo.tt' ) %]
+ [% CALL dw.ml_scope( old_scope ) %]
=cut
sub ml_scope {
- return DW::Request->get->note( 'ml_scope', $_[1] );
+ my $r = DW::Request->get;
+ return $#_ == 1 ? $r->note( 'ml_scope', $_[1] ) : $r->note( 'ml_scope' );
}
-
-=head1 FILTERS
-
-=head2 ml
-
-Apply a ML string.
-
- [% '.foo' | ml(arg = 'bar') %]
-
-=cut
=head1 AUTHOR
@@ -98,4 +94,4 @@ the same terms as Perl itself. For a cop
=cut
-1;
\ No newline at end of file
+1;
--------------------------------------------------------------------------------
