Module: Virgo::RenderHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/virgo/render_helper.rb
Instance Method Summary collapse
-
#render_content(*args, &block) ⇒ Object
render_to_string, except force formats = [:html] if none are explicitly provided (so you can call from a controller action body responding to a json request and still render out a html partial by default).
- #with_format(format, &block) ⇒ Object
Instance Method Details
#render_content(*args, &block) ⇒ Object
render_to_string, except force formats = [:html] if none are explicitly provided (so you can call from a controller action body responding to a json request and still render out a html partial by default)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/virgo/render_helper.rb', line 15 def render_content(*args, &block) augmented_args = _normalize_args(*args, &block) augmented_args[:formats] ||= [] augmented_args[:formats] = [:html] unless augmented_args[:formats].include?(:html) # declare so below reference is not block-local content = "" # necessary to not receive warnings (see above) with_format :html do content = render_to_string(augmented_args) end content.html_safe end |
#with_format(format, &block) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/virgo/render_helper.rb', line 3 def with_format(format, &block) old_formats = formats self.formats = [format] block.call self.formats = old_formats nil end |