mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-31 13:50:23 +02:00
refactor: html format (#3062)
* refactor: html format Fix a few small bugs too * fix * fix * trigger build * striptags instead of encode title
This commit is contained in:
@@ -42,7 +42,7 @@ interface FormatInterface
|
||||
* Return items
|
||||
*
|
||||
* @throws \LogicException if the items are not set
|
||||
* @return array The items
|
||||
* @return FeedItem[] The items
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
|
13
lib/html.php
13
lib/html.php
@@ -18,15 +18,26 @@ function render(string $template, array $context = []): string
|
||||
return render_template('base.html.php', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render template as absolute path or relative to templates folder.
|
||||
* Do not pass user input in $template
|
||||
*/
|
||||
function render_template(string $template, array $context = []): string
|
||||
{
|
||||
if (isset($context['template'])) {
|
||||
throw new \Exception("Don't use `template` as a context key");
|
||||
}
|
||||
$templateFilepath = __DIR__ . '/../templates/' . $template;
|
||||
extract($context);
|
||||
ob_start();
|
||||
try {
|
||||
require __DIR__ . '/../templates/' . $template;
|
||||
if (is_file($template)) {
|
||||
require $template;
|
||||
} elseif (is_file($templateFilepath)) {
|
||||
require $templateFilepath;
|
||||
} else {
|
||||
throw new \Exception(sprintf('Unable to find template `%s`', $template));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
ob_end_clean();
|
||||
throw $e;
|
||||
|
Reference in New Issue
Block a user