From 8817f25b3b69622f98edfc74393ae8d88f827b7a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 5 Mar 2013 13:14:00 +0100 Subject: [PATCH] Presenter: escape_js() zum Escapen von JavaScript --- SL/Presenter.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/SL/Presenter.pm b/SL/Presenter.pm index f328cce9e..36acc73dd 100644 --- a/SL/Presenter.pm +++ b/SL/Presenter.pm @@ -124,6 +124,16 @@ sub escaped_text { return SL::Presenter::EscapedText->new(text => $text, is_escaped => 1); } +sub escape_js { + my ($self, $text) = @_; + + $text =~ s|\\|\\\\|g; + $text =~ s|\"|\\\"|g; + $text =~ s|\n|\\n|g; + + return SL::Presenter::EscapedText->new(text => $text, is_escaped => 1); +} + 1; __END__ @@ -290,6 +300,16 @@ It is safe to call C on an instance of L. This is a no-op (the same instance will be returned). +=item C + +Returns a JavaScript-escaped version of C<$text>. Instead of a string +an instance of the thin proxy-object L is +returned. + +It is safe to call C on an instance of +L. This is a no-op (the same instance will +be returned). + =item C Returns the global instance of L