Module: Hiccdown::ViewHelpers::MethodOverrides
- Defined in:
- lib/hiccdown.rb
Class Method Summary collapse
Class Method Details
.prepended(base) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hiccdown.rb', line 16 def self.prepended(base) # `capture` is at the root of seemingly all Rails methods tasked with # rendering content, including `content_tag` and `tag`, which in turn # are used for `link_to`, `form_for`, etc. define_method(:capture) do |*args, **kwargs, &block| if block super(*args, **kwargs) do |*brgs, **jwargs| result = block.call(*brgs, *jwargs) result.is_a?(Array) ? Hiccdown::to_html(result).html_safe : result end else super(*args, **kwargs) end end end |