Class: Hiccdown::Renderable

Inherits:
Object
  • Object
show all
Defined in:
lib/hiccdown/railtie.rb

Instance Method Summary collapse

Constructor Details

#initialize(helper_module, action_name) ⇒ Renderable

Returns a new instance of Renderable.



16
17
18
19
# File 'lib/hiccdown/railtie.rb', line 16

def initialize(helper_module, action_name)
  @helper_module = helper_module
  @action_name = action_name
end

Instance Method Details

#formatObject



29
30
31
# File 'lib/hiccdown/railtie.rb', line 29

def format
  :html
end

#render_in(view_context) ⇒ Object

This is the view-bound view_context. Needed for ‘content_for` to work properly in helper, see stackoverflow.com/a/78783866/1371131



23
24
25
26
27
# File 'lib/hiccdown/railtie.rb', line 23

def render_in(view_context)
  content = @helper_module.instance_method(@action_name).bind_call(view_context)

  Hiccdown::to_html(content)
end