NAME
HTML::Highlighter - PSGI middleware to highlight text in an HTML response
SYNOPSIS
use Plack::Builder;
use HTML::Highlighter;
# highlight the "search" query param
builder {
enable "+HTML::Highlighter", param => "search";
...
$app;
};
# or highlight the user stored in session
builder {
enable "+HTML::Highlighter", callback => sub {
my $env = shift;
$env->{'psgix.highlight'} = $env->{'psgix.session'}{user};
};
...
$app;
};
DESCRIPTION
The HTML::Highlighter
module is a piece of PSGI middleware that will inspect an HTML response and highlight parts of the page based on a query parameter or other request data. This is very much like what Google does when you load a page from their cache. Any text that matches your original query is highlighted.
<span class="highlight">[matching text]</span>
This module also includes a javascript file called highlighter.js which gives you a class with methods to jump (scroll) through the highlights.
CONSTRUCTOR PARAMETERS
- param
-
This option allows you to specify a query parameter to be used for the highlighting. For example, if you specify "search" as the param, each response will look for a query parameter called "search" will highlight that value in the response.
- callback
-
This option lets you specify a function that will be called on each request to generate the text used for highlighting. The function will be passed the $env hashref, and should set 'psgix.highlight' on it. This value will be used for the highlighting. This could be useful if you want to highlight a username that is stored in a session, or something similar.
SEE ALSO
COPYRIGHT AND LICENSE
Copyright (C) 2010 Lee Aylward <leedo at cpan.org>, all rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Lee Aylward, <leedo@cpan.org>