Skip to content

Instantly share code, notes, and snippets.

@jacksleight
Last active October 28, 2021 09:38
Show Gist options
  • Save jacksleight/e30b9cda9594def4cdf9667c345a74df to your computer and use it in GitHub Desktop.
Save jacksleight/e30b9cda9594def4cdf9667c345a74df to your computer and use it in GitHub Desktop.
Statamic Antlers Blade Tag
<?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