Revision a30abed7
Von Moritz Bunkus vor etwa 3 Jahren hinzugefügt
SL/Presenter/Text.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use SL::Presenter::EscapedText qw(escape); |
6 |
use SL::HTML::Restrict; |
|
6 | 7 |
|
7 | 8 |
use Exporter qw(import); |
8 |
our @EXPORT_OK = qw(format_man_days simple_format truncate); |
|
9 |
our @EXPORT_OK = qw(format_man_days simple_format truncate restricted_html);
|
|
9 | 10 |
our %EXPORT_TAGS = (ALL => \@EXPORT_OK); |
10 | 11 |
|
11 | 12 |
use Carp; |
12 | 13 |
|
14 |
my $html_cleaner; |
|
15 |
|
|
13 | 16 |
sub truncate { |
14 | 17 |
my ($text, %params) = @_; |
15 | 18 |
|
... | ... | |
43 | 46 |
escape($output); |
44 | 47 |
} |
45 | 48 |
|
49 |
sub restricted_html { |
|
50 |
my ($value) = @_; |
|
51 |
$html_cleaner //= SL::HTML::Restrict->create; |
|
52 |
return $html_cleaner->process($value); |
|
53 |
} |
|
54 |
|
|
46 | 55 |
1; |
47 | 56 |
__END__ |
48 | 57 |
|
... | ... | |
89 | 98 |
one. Single newlines are converted to line breaks. Carriage returns |
90 | 99 |
are removed. |
91 | 100 |
|
101 |
=item C<restricted_html $unsafe_html> |
|
102 |
|
|
103 |
Returns HTML code stripped from unwanted/unsupported content. This is |
|
104 |
done via the module L<SL::HTML::Restrict>. |
|
105 |
|
|
92 | 106 |
=back |
93 | 107 |
|
94 | 108 |
=head1 BUGS |
SL/Template/Plugin/L.pm | ||
---|---|---|
85 | 85 |
sub div_tag { return _call_presenter('div_tag', @_); } |
86 | 86 |
sub radio_button_tag { return _call_presenter('radio_button_tag', @_); } |
87 | 87 |
sub img_tag { return _call_presenter('img_tag', @_); } |
88 |
sub restricted_html { return _call_presenter('restricted_html', @_); } |
|
88 | 89 |
|
89 | 90 |
sub _set_id_attribute { |
90 | 91 |
my ($attributes, $name, $unique) = @_; |
Auch abrufbar als: Unified diff
L/Presenter: Funktion zum Säubern von HTML von unerwünschten Tags