fix registering template paths
This commit is contained in:
@@ -345,9 +345,9 @@ template file of your own in your plugin, you need a new path:
|
|||||||
register_template_path(
|
register_template_path(
|
||||||
dist_dir( 'App-Netdisco-Web-Plugin-Search-MyNewFeature' ));
|
dist_dir( 'App-Netdisco-Web-Plugin-Search-MyNewFeature' ));
|
||||||
|
|
||||||
The registered path will be searched before the built-in C<App::Netdisco>
|
The "C<views>" subdirectory of the registered path will be searched before the
|
||||||
path. We recommend use of the L<File::ShareDir> module to package and ship
|
built-in C<App::Netdisco> path. We recommend use of the L<File::ShareDir>
|
||||||
templates along with your plugin, as shown.
|
module to package and ship templates along with your plugin, as shown.
|
||||||
|
|
||||||
Each path added using C<register_template_path> is searched I<before> any
|
Each path added using C<register_template_path> is searched I<before> any
|
||||||
existing paths in the template config. See the
|
existing paths in the template config. See the
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ use Module::Find ();
|
|||||||
use Module::Load ();
|
use Module::Load ();
|
||||||
use App::Netdisco::Util::Web 'interval_to_daterange';
|
use App::Netdisco::Util::Web 'interval_to_daterange';
|
||||||
|
|
||||||
|
# FIXME: need to avoid splat so that this can be reordered
|
||||||
|
Module::Find::usesub 'App::Netdisco::Web::Auto';
|
||||||
Module::Find::usesub 'App::Netdisco::Web';
|
Module::Find::usesub 'App::Netdisco::Web';
|
||||||
Module::Find::usesub 'App::Netdisco::Auto::Web';
|
|
||||||
|
|
||||||
sub _load_web_plugins {
|
sub _load_web_plugins {
|
||||||
my $plugin_list = shift;
|
my $plugin_list = shift;
|
||||||
@@ -40,6 +41,10 @@ if (setting('extra_web_plugins') and ref [] eq ref setting('extra_web_plugins'))
|
|||||||
_load_web_plugins( setting('extra_web_plugins') );
|
_load_web_plugins( setting('extra_web_plugins') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# after plugins are loaded, add our own template path
|
||||||
|
push @{ config->{engines}->{template_toolkit}->{INCLUDE_PATH} },
|
||||||
|
setting('views');
|
||||||
|
|
||||||
# workaround for https://github.com/PerlDancer/Dancer/issues/935
|
# workaround for https://github.com/PerlDancer/Dancer/issues/935
|
||||||
hook after_error_render => sub { setting('layout' => 'main') };
|
hook after_error_render => sub { setting('layout' => 'main') };
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,8 @@ register 'register_template_path' => sub {
|
|||||||
return error "bad template path to register_template_paths";
|
return error "bad template path to register_template_paths";
|
||||||
}
|
}
|
||||||
|
|
||||||
unshift
|
push @{ config->{engines}->{template_toolkit}->{INCLUDE_PATH} },
|
||||||
@{ config->{engines}->{template_toolkit}->{INCLUDE_PATH} },
|
dir($path, 'views')->stringify;
|
||||||
$path, dir($path, 'views')->stringify;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sub _register_include {
|
sub _register_include {
|
||||||
|
|||||||
@@ -223,6 +223,7 @@ engines:
|
|||||||
start_tag: '[%'
|
start_tag: '[%'
|
||||||
end_tag: '%]'
|
end_tag: '%]'
|
||||||
PRE_CHOMP: 1
|
PRE_CHOMP: 1
|
||||||
|
INCLUDE_PATH: []
|
||||||
layout: 'main'
|
layout: 'main'
|
||||||
plugins:
|
plugins:
|
||||||
Auth::Extensible:
|
Auth::Extensible:
|
||||||
|
|||||||
Reference in New Issue
Block a user