From 70654da2c4f2ea4e4e22a2b6928954c56b9746f6 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 11 Jan 2016 16:32:34 +0100 Subject: [PATCH] =?utf8?q?Revert=20"JavaScript-Plugin:=20auch=20als=20Filt?= =?utf8?q?er=20einsetzen=20k=C3=B6nnen"?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Dies revertet Commit 20d730acdbb52b5b75af783aa010609e25b73024. Grund ist, dass aus bisher nicht zu analysierenden Gründen in manchen Situationen der Template-Toolkit-Compiler oder eine andere Komponente Quark erzeugt und daher das Plugin nicht findet. Wenn es geht, dann sieht das compilierte Template an der Stelle wie folgt aus: ------ snip ------ $output .= do { my $output = ''; my $_tt_filter = $context->filter('js') || $context->throw($context->error); ------ snip ------ Wenn es aber nicht geht, dann wie folgt: ------ snip ------ $output .= do { my $output = ''; my $_tt_filter = $context->filter($stash->get('js')) || $context->throw($context->error); ------ snip ------ Im nicht funktionierenden Fall wird das Plugin selber im Stash gesucht, wo es aber nicht vorhanden ist. Warum das passiert ist noch rätselhaft und wird mangels Zeit erst einmal nicht weiter untersucht. --- SL/Template/Plugin/JavaScript.pm | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/SL/Template/Plugin/JavaScript.pm b/SL/Template/Plugin/JavaScript.pm index 48158307f..16989e9a2 100644 --- a/SL/Template/Plugin/JavaScript.pm +++ b/SL/Template/Plugin/JavaScript.pm @@ -1,23 +1,16 @@ package SL::Template::Plugin::JavaScript; -use base qw( Template::Plugin::Filter ); +use base qw( Template::Plugin ); +use Template::Plugin; use strict; -my $cached_instance; - sub new { - my $class = shift; - - return $cached_instance ||= $class->SUPER::new(@_); -} - -sub init { - my $self = shift; - - $self->install_filter($self->{ _ARGS }->[0] || 'js'); + my ($class, $context, @args) = @_; - return $self; + return bless { + CONTEXT => $context, + }, $class; } # @@ -45,11 +38,6 @@ sub escape { return $text; } -sub filter { - my ($self, $text) = @_; - return $self->escape($text); -} - sub replace_with { return _replace_helper('replaceWith', @_); } @@ -104,11 +92,6 @@ value is not wrapped in quotes. Example: -You can also use the filter syntax instead: - - - =item C Returns code replacing the DOM elements matched by C<$selector> with -- 2.20.1