Ein Template-Plugin zum Escape von Angaben für JavaScript-Strings.
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 7 Jan 2008 15:36:24 +0000 (15:36 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 7 Jan 2008 15:36:24 +0000 (15:36 +0000)
SL/Template/Plugin/JavaScript.pm [new file with mode: 0644]

diff --git a/SL/Template/Plugin/JavaScript.pm b/SL/Template/Plugin/JavaScript.pm
new file mode 100644 (file)
index 0000000..467c591
--- /dev/null
@@ -0,0 +1,24 @@
+package SL::Template::Plugin::JavaScript;
+
+use base qw( Template::Plugin );
+use Template::Plugin;
+
+sub new {
+  my $class   = shift;
+  my $context = shift;
+
+  bless { }, $class;
+}
+
+sub escape {
+  my $self = shift;
+  my $text = shift;
+
+  $text =~ s|\"|\\\"|g;
+
+  return $text;
+}
+
+1;
+
+