diff --git a/plugins/AttachmentShowRelated/AttachmentShowRelated.php b/plugins/AttachmentShowRelated/AttachmentShowRelated.php index 5959e4f444..d19d98c683 100644 --- a/plugins/AttachmentShowRelated/AttachmentShowRelated.php +++ b/plugins/AttachmentShowRelated/AttachmentShowRelated.php @@ -37,8 +37,8 @@ class AttachmentShowRelated extends Plugin $related_tags = DB::dql('select distinct t.tag ' . 'from attachment_to_note an join note_tag t with an.note_id = t.note_id ' . 'where an.attachment_id = :attachment_id', ['attachment_id' => $vars['vars']['attachment_id']]); - $res[] = Formatting::twigRender(file_get_contents(__DIR__ . '/templates/AttachmentRelatedNotes.html.twig'), ['related_notes' => $related_notes]); - $res[] = Formatting::twigRender(file_get_contents(__DIR__ . '/templates/AttachmentRelatedTags.html.twig'), ['related_tags' => $related_tags]); + $res[] = Formatting::twigRenderFile('attachmentShowRelated/attachmentRelatedNotes.html.twig', ['related_notes' => $related_notes]); + $res[] = Formatting::twigRenderFile('attachmentShowRelated/attachmentRelatedTags.html.twig', ['related_tags' => $related_tags]); } return Event::next; } diff --git a/plugins/AttachmentShowRelated/templates/AttachmentRelatedNotes.html.twig b/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedNotes.html.twig similarity index 100% rename from plugins/AttachmentShowRelated/templates/AttachmentRelatedNotes.html.twig rename to plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedNotes.html.twig diff --git a/plugins/AttachmentShowRelated/templates/AttachmentRelatedTags.html.twig b/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedTags.html.twig similarity index 100% rename from plugins/AttachmentShowRelated/templates/AttachmentRelatedTags.html.twig rename to plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedTags.html.twig diff --git a/plugins/Embed/Embed.php b/plugins/Embed/Embed.php index 6bba39e919..390ab9b525 100644 --- a/plugins/Embed/Embed.php +++ b/plugins/Embed/Embed.php @@ -208,7 +208,7 @@ class Embed extends Plugin $smart_crop = Common::config('thumbnail', 'smart_crop'); $attributes = $embed->getImageHTMLAttributes(['class' => 'u-photo embed']); - $res[] = Formatting::twigRender(<<
{% if attributes != false %} diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index 7f542f2f22..34d2745ad4 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -77,7 +77,7 @@ class Favourite extends Plugin public function onInsertLeftPanelLink(string $user_nickname, &$res): bool { - $res[] = Formatting::twigRender(<<Favourites Reverse Favs END, ['user_nickname' => $user_nickname]); diff --git a/src/Util/Formatting.php b/src/Util/Formatting.php index 63b6f50cc0..cf6cb79d57 100644 --- a/src/Util/Formatting.php +++ b/src/Util/Formatting.php @@ -43,11 +43,16 @@ abstract class Formatting self::$twig = $twig; } - public static function twigRender(string $template, array $context): string + public static function twigRenderString(string $template, array $context): string { return self::$twig->createTemplate($template, null)->render($context); } + public static function twigRenderFile(string $template, array $context): string + { + return self::$twig->render($template, $context); + } + /** * Normalize path by converting \ to / *