Skip to content

Instantly share code, notes, and snippets.

@duncanmcclean
Created January 16, 2022 22:00
Show Gist options
  • Save duncanmcclean/19651c5d06d7fbcb2ae3cdadf87785d1 to your computer and use it in GitHub Desktop.
Save duncanmcclean/19651c5d06d7fbcb2ae3cdadf87785d1 to your computer and use it in GitHub Desktop.
<?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