Skip to content

Commit

Permalink
Resolve template when previewing
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Mar 25, 2024
1 parent b8c29b5 commit 7be55f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 4.14.1 - 2024-03-25

### Changed

- Cached and dynamic includes are now resolved as regular includes when previewing an element ([#646](https://github.com/putyourlightson/craft-blitz/issues/646)).

### Fixed

- Fixed an error that could be thrown when returning to a page via the breadcrumbs in the Blitz Diagnostics utility ([#645](https://github.com/putyourlightson/craft-blitz/issues/645)).
Expand Down
4 changes: 4 additions & 0 deletions src/variables/BlitzVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ private function includeTemplate(string $template, string $uriPrefix, string $ac
throw new NotFoundHttpException('Template not found: ' . $template);
}

if (Craft::$app->getRequest()->getIsPreview() || Craft::$app->getRequest()->getIsLivePreview()) {
return Template::raw(Craft::$app->getView()->renderTemplate($template, $params));
}

$siteId = Craft::$app->getSites()->getCurrentSite()->id;

[$includeId, $index] = Blitz::$plugin->generateCache->saveInclude($siteId, $template, $params);
Expand Down

0 comments on commit 7be55f7

Please sign in to comment.