- # Don't use htmllink because this way the
- # title is separate and can be overridden by
- # other plugins.
- my $link=bestlink($params{page}, $page);
- $link=htmlpage($link) if defined $type;
- $link=abs2rel($link, dirname($params{destpage}));
- $template->param(pageurl => $link);
- $template->param(title => pagetitle(basename($page)));
- $template->param(ctime => displaytime($pagectime{$page}));
-
- if ($actions) {
- my $file = $pagesources{$page};
- my $type = pagetype($file);
- if ($config{discussion}) {
- my $discussionlink=gettext("discussion");
- if ($page !~ /.*\/\Q$discussionlink\E$/ &&
- (length $config{cgiurl} ||
- exists $links{$page."/".$discussionlink})) {
+ if (! $template) {
+ error sprintf(gettext("template %s not found"), $params{template}.".tmpl");
+ }
+ }
+ my $needcontent=$raw || (!($archive && $quick) && $template->query(name => 'content'));
+
+ foreach my $page (@list) {
+ my $file = $pagesources{$page};
+ my $type = pagetype($file);
+ if (! $raw) {
+ if ($needcontent) {
+ # Get the content before populating the
+ # template, since getting the content uses
+ # the same template if inlines are nested.
+ my $content=get_inline_content($page, $params{destpage});
+ $template->param(content => $content);
+ }
+ $template->param(pageurl => urlto($page, $params{destpage}));
+ $template->param(inlinepage => $page);
+ $template->param(title => pagetitle(basename($page)));
+ $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}, 1));
+ $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
+ $template->param(first => 1) if $page eq $list[0];
+ $template->param(last => 1) if $page eq $list[$#list];
+
+ if ($actions) {
+ my $file = $pagesources{$page};
+ my $type = pagetype($file);
+ if ($config{discussion}) {
+ if ($page !~ /.*\/\Q$config{discussionpage}\E$/i &&
+ (length $config{cgiurl} ||
+ exists $pagesources{$page."/".lc($config{discussionpage})})) {
+ $template->param(have_actions => 1);
+ $template->param(discussionlink =>
+ htmllink($page,
+ $params{destpage},
+ $config{discussionpage},
+ noimageinline => 1,
+ forcesubpage => 1));
+ }
+ }
+ if (length $config{cgiurl} &&
+ defined $type &&
+ IkiWiki->can("cgi_editpage")) {