Created
May 26, 2022 08:04
-
-
Save duncanmcclean/18f0ba9de48f086d51f8f9b631bc70cc 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
<div class="my-2 w-full torchlight-parent"> | |
{{ torchlight :language="language" }} | |
{{ code | noparse | entities }} | |
{{ /torchlight }} | |
</div> |
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