« lib/WWW/Shopify/Liquid/Dialect/Web/Filter/EscapeJS.pm
↑ Summary
lib/WWW/Shopify/Liquid/Dialect/Web/Filter/UrlEscape.pm »
| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | |||
| 4 | package WWW::Shopify::Liquid::Dialect::Web::Filter::Highlight; | ||
| 5 | use base 'WWW::Shopify::Liquid::Filter'; | ||
| 6 | |||
| 7 | sub min_arguments { return 1; } | ||
| 8 | sub max_arguments { return 1; } | ||
| 9 | sub operate { | ||
| 10 | my ($self, $hash, $operand, $terms) = @_; | ||
| 11 | my $replacement = "(" . join("|", map { quotemeta($_) } (ref($terms) && ref($terms) eq 'ARRAY' ? @$terms : $terms)) . ")"; | ||
| 12 | $operand =~ s/$replacement/<strong>$1<\/strong>/ig; | ||
| 13 | return $operand; | ||
| 14 | } | ||
| 15 | |||
| 16 | 1; |