From: Matt S Trout Date: Fri, 3 Aug 2012 20:16:03 +0000 (+0000) Subject: $page->body, custom plugin loading X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1896819232399283544d5c784e735a02aa49fd3e;p=scpubgit%2FApp-SCS.git $page->body, custom plugin loading --- diff --git a/lib/App/SCS.pm b/lib/App/SCS.pm index ca1d791..a4d7b02 100644 --- a/lib/App/SCS.pm +++ b/lib/App/SCS.pm @@ -70,9 +70,10 @@ sub BUILD { sub load_plugin { my ($self, $name, $config) = @_; + my $class = ($name =~ s/^\+// ? $name : "App::SCS::Plugin::${name}"); push( @{$self->plugins}, - use_module("App::SCS::Plugin::${name}")->new( + use_module($class)->new( app => $self, config => $config ) diff --git a/lib/App/SCS/Page.pm b/lib/App/SCS/Page.pm index 0c2e76f..8cc33d9 100644 --- a/lib/App/SCS/Page.pm +++ b/lib/App/SCS/Page.pm @@ -5,6 +5,7 @@ use Time::Local qw(timelocal); use Data::Pond qw(pond_read_datum pond_write_datum); use List::Util qw(reduce); use Module::Runtime qw(use_module); +use HTML::Zoom; use Moo; has "_$_" => (is => 'ro', init_arg => $_) for qw(page_set); @@ -114,6 +115,14 @@ sub _html_zoom { } HTML::Zoom->from_html($self->html), @{$self->_page_plugins}; } +sub body { + my ($self) = @_; + HTML::Zoom->from_html($self->html) + ->collect(body => { into => \my @ev }) + ->run; + HTML::Zoom->from_events(\@ev)->to_html; +} + no Moo; sub with {