]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/Template/Plugin/JavaScript.pm
Ein Template-Plugin zum Escape von Angaben für JavaScript-Strings.
[kivitendo-erp.git] / SL / Template / Plugin / JavaScript.pm
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;
+
+