[UTIL][Formatting] Add twigRenderFile
This commit is contained in:
parent
e9a96f1c9b
commit
837f644458
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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(<<<END
|
||||
$res[] = Formatting::twigRenderString(<<<END
|
||||
<article class="h-entry embed">
|
||||
<header>
|
||||
{% if attributes != false %}
|
||||
|
|
|
@ -77,7 +77,7 @@ class Favourite extends Plugin
|
|||
|
||||
public function onInsertLeftPanelLink(string $user_nickname, &$res): bool
|
||||
{
|
||||
$res[] = Formatting::twigRender(<<<END
|
||||
$res[] = Formatting::twigRenderString(<<<END
|
||||
<a href="{{ path("favourites", {'nickname' : user_nickname}) }}" class='hover-effect {{ active("favourites") }}'>Favourites</a>
|
||||
<a href="{{ path("reverse_favourites", {'nickname' : user_nickname}) }}" class='hover-effect {{ active("reverse_favourites") }}'>Reverse Favs</a>
|
||||
END, ['user_nickname' => $user_nickname]);
|
||||
|
|
|
@ -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 /
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user