Created
September 28, 2022 16:03
-
-
Save braindeaf/b2985aee35ab93f515c66fdc348c5bcf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module Haml::Filters::CodeConcern | |
extend ActiveSupport::Concern | |
def render(text) | |
<<~CODE | |
<div class="sa-code-snippet-wrapper"> | |
<div class="sa-code-snippet"> | |
<div class="code-title">HAML Snippet</div> | |
<button class="copy-code-button">Copy</button> | |
<pre class="chroma"><code>#{Haml::Helpers.preserve text}</code></pre> | |
</div> | |
</div> | |
CODE | |
end | |
end | |
if Haml::VERSION >= '6.0.0' | |
module Haml | |
class Filters | |
class Code < Haml::Filters::Base | |
include CodeConcern | |
def compile(node) | |
[:static, render(node.value[:text])] | |
end | |
end | |
register :code, Code | |
end | |
end | |
else | |
module Haml::Filters::Code | |
include Haml::Filters::Base | |
include Haml::Filters::CodeConcern | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment