Skip to content

Commit

Permalink
add lightbox helper to IIblog
Browse files Browse the repository at this point in the history
  • Loading branch information
genehack committed Aug 17, 2017
1 parent 7e7928d commit 4c62e18
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/HiD/Processor/IIBlog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use warnings qw/ FATAL utf8 /;
use open qw/ :std :utf8 /;
use charnames qw/ :full /;

use Text::Xslate;
use Text::Xslate qw/ mark_raw /;

has 'txs' => (
is => 'ro' ,
Expand All @@ -48,6 +48,7 @@ sub BUILDARGS {
function => {
commafy => sub { my $a = shift; join ',' , @$a },
lc => sub { lc( shift ) } ,
lightbox => \&lightbox,
pretty_date => sub { shift->strftime( "%d %b %Y" ) },
} ,
path => $path,
Expand All @@ -68,5 +69,19 @@ sub process {
return 1;
}

sub _lightbox {
my %args = @_;

my $img = $args{img} // die "lightbox needs img arg";
my $width = $args{width} //= 300;
my $alt = $args{alt} // die "lightbox needs alt arg";

return mark_raw(<<EOHTML);
<a href="$img" class="lightbox">
<img src="$img" width="$width" alt="$alt" />
</a>
EOHTML
}

__PACKAGE__->meta->make_immutable;
1;

0 comments on commit 4c62e18

Please sign in to comment.