I want to render a Twig template in an API endpoint. Specifically I need HTML for the JSON Feed field "content_html".
My attempts until now (inside the transformer function):
$view = Craft::$app->getView(); $template = $view->resolveTemplate('_blog-entry'); // first attempt: $html = $view->render($template, ['entry' => $blogpost]); // second attempt: $controller = Craft::$app->createController('templates/render'); $html = $controller->render($template, ['entry' => $blogpost])
But in both ways it says "Template not found" even if the path after the "resolveTemplate" is correct.
Has anybody an idea how to do it? Thanks!