mirror of
https://github.com/flextype/flextype.git
synced 2025-08-06 13:16:45 +02:00
feat(shortcodes): add ability to use php directive with php
shortcode
This commit is contained in:
@@ -24,8 +24,12 @@ parsers()->shortcodes()->addHandler('php', static function (ShortcodeInterface $
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.php.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
eval($s->getContent());
|
||||
return ob_get_clean();
|
||||
|
||||
if ($s->getContent() != null) {
|
||||
ob_start();
|
||||
eval($s->getContent());
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
return '@php';
|
||||
});
|
@@ -2,7 +2,17 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('[php] shortcode', function () {
|
||||
$this->assertEquals("Foo",
|
||||
parsers()->shortcodes()->parse('(php)echo "Foo";(/php)'));
|
||||
beforeEach(function() {
|
||||
filesystem()->directory(PATH['project'] . '/entries')->ensureExists(0755, true);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
filesystem()->directory(PATH['project'] . '/entries')->delete();
|
||||
});
|
||||
|
||||
test('php shortcode', function () {
|
||||
$this->assertEquals("Foo", parsers()->shortcodes()->parse('(php)echo "Foo";(/php)'));
|
||||
|
||||
expect(entries()->create('bar', ['test' => '(php) echo "Bar";']))->toBeTrue();
|
||||
expect(entries()->fetch('bar')['test'])->toBe('Bar');
|
||||
});
|
||||
|
Reference in New Issue
Block a user