Module: Hiccdown::ViewHelpers::RenderingHelperOverrides
- Defined in:
- lib/hiccdown.rb
Class Method Summary collapse
Class Method Details
.prepended(base) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hiccdown.rb', line 35 def self.prepended(base) # This teaches the view renderer (which is different from the controller renderer, # h/t https://stackoverflow.com/questions/78801079/rails-custom-renderer-for-turbo-stream?noredirect=1#comment138933498_78801079) # to accept a `:hiccdown` option, thus enabling the rendering of hiccdown in turbo-stream # actions as well: # `turbo_stream.update(..., hiccdown: [:h1, 'hello world']) define_method(:render) do | = {}, locals = {}, &block| if .is_a?(Hash) && .key?(:hiccdown) Hiccdown.to_html([:hiccdown]).html_safe else super(, locals, &block) end end end |