initial import of App::SCS code
[scpubgit/App-SCS.git] / lib / App / SCS / Plugin / Core / PagePlugin / Template.pm
CommitLineData
632f0e07 1package App::SCS::Plugin::Core::PagePlugin::Template;
2
3use Moo;
4
5with 'App::SCS::Role::PagePlugin';
6
7has templates => (is => 'ro', required => 1);
8
9has name => (is => 'ro', required => 1);
10
11sub filter_html_zoom {
12 my ($self, $zoom) = @_;
13 my $template_page = $self->templates->get({ path => $self->name })
14 or die "No such template ${\$self->name}";
15 my $template_zoom = HTML::Zoom->from_html($template_page->html);
16 my @ev;
17 $template_zoom->collect('*[data-replace]', { into => \@ev })
18 ->then
19 ->${\sub {
20 my $sel = $ev[0]->{attrs}{'data-replace'};
21 $zoom->collect($self, { into => \my @replace })->run;
22 shift->replace(\@replace);
23 }}
24}
25
261;