Last active
October 28, 2021 09:38
-
-
Save jacksleight/e30b9cda9594def4cdf9667c345a74df to your computer and use it in GitHub Desktop.
Statamic Antlers Blade Tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Tags; | |
use Statamic\Tags\Tags; | |
use Symfony\Component\Debug\Exception\FatalThrowableError; | |
class Blade extends Tags | |
{ | |
public function index() | |
{ | |
$__php = \Blade::compileString($this->content); | |
$__env = view(); | |
$obLevel = ob_get_level(); | |
ob_start(); | |
extract($this->params->all(), EXTR_SKIP); | |
try { | |
eval('?' . '>' . $__php); | |
} catch (\Exception $e) { | |
while (ob_get_level() > $obLevel) ob_end_clean(); | |
throw $e; | |
} catch (\Throwable $e) { | |
while (ob_get_level() > $obLevel) ob_end_clean(); | |
throw new FatalThrowableError($e); | |
} | |
return ob_get_clean(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment