Created
January 16, 2022 22:00
-
-
Save duncanmcclean/19651c5d06d7fbcb2ae3cdadf87785d1 to your computer and use it in GitHub Desktop.
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 Torchlight\Blade\BladeManager; | |
use Torchlight\Block; | |
class Torchlight extends Tags | |
{ | |
/** | |
* {{ torchlight language="php" }}{{ my_code }}{{ /torchlight }} | |
*/ | |
public function index() | |
{ | |
$language = $this->params->get('language'); | |
$code = $this->context->raw('code'); | |
$block = Block::make() | |
->language($language) | |
->code($code) | |
->theme(config('torchlight.theme')); | |
BladeManager::registerBlock($block); | |
$render = function (Block $block) { | |
return "<pre><code class='{$block->placeholder('classes')}' style='{$block->placeholder('styles')}'>{$block->placeholder()}</code></pre>"; | |
}; | |
return $render($block); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment