Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1e0c2679

Von Sven Schöling vor mehr als 3 Jahren hinzugefügt

  • ID 1e0c26795a315e10345a6aafc0ca9b5aa42a0755
  • Vorgänger 383871e4
  • Nachfolger e6aeed03

Presenter::EscapedText: escape_js_calls

Helferfunktion um das manuelle Zusammenstückeln von onclick Callbacks zu
erleichtern.

Unterschiede anzeigen:

SL/Presenter/EscapedText.pm
use strict;
use Exporter qw(import);
use Scalar::Util qw(looks_like_number);
our @EXPORT_OK = qw(escape is_escaped escape_js);
our @EXPORT_OK = qw(escape is_escaped escape_js escape_js_call);
our %EXPORT_TAGS = (ALL => \@EXPORT_OK);
use JSON ();
......
__PACKAGE__->new(text => $text, is_escaped => 1);
}
sub escape_js_call {
my ($func, @args) = @_;
escape(
sprintf "%s(%s)",
escape_js($func),
join ", ", map {
looks_like_number($_)
? $_
: '"' . escape_js($_) . '"'
} @args
);
}
# internal magic
sub escaped_text {
my ($self) = @_;
......
Static constructor, can be exported. Like C<escape> but also escapes Javascript.
=item C<escape_js_call $func_name, @args>
Static constructor, can be exported. Used to construct a javascript call than
can be used for onclick handlers in other Presenter functions.
For example:
L.button_tag(
P.escape_js_call("kivi.Package.some_func", arg_one, arg_two, arg_three)
title
)
=back
=head1 METHODS

Auch abrufbar als: Unified diff