From 69a292a5b3ea95595555f4a92287c59c7b4c2fa5 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Mon, 9 Jan 2017 19:32:16 -0800 Subject: [PATCH] Add shared `$post` variable to Blade --- src/setup.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/setup.php b/src/setup.php index b60ab26..0d4227d 100644 --- a/src/setup.php +++ b/src/setup.php @@ -89,6 +89,14 @@ add_action('widgets_init', function () { ] + $config); }); +/** + * Updates the `$post` variable on each iteration of the loop. + * Note: updated value is only available for subsequently loaded views, such as partials + */ +add_action('the_post', function ($post) { + sage('blade')->share('post', $post); +}); + /** * Setup Sage options */