Class: Crumpet::Renderer
- Inherits:
-
Object
- Object
- Crumpet::Renderer
- Includes:
- ActionView::Helpers::UrlHelper, ERB::Util
- Defined in:
- lib/crumpet/renderer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Renderer
Returns a new instance of Renderer.
8 9 10 |
# File 'lib/crumpet/renderer.rb', line 8 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/crumpet/renderer.rb', line 6 def @options end |
Instance Method Details
#render ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/crumpet/renderer.rb', line 12 def render case option_or_default(:format) when :html output = crumbs.map{ |crumb| render_html(crumb) }.join(option_or_default(:separator)).html_safe output = content_tag(option_or_default(:container).to_sym, output, ) if option_or_default(:container).present? output when :xml output = crumbs.map{ |crumb| render_xml(crumb) }.join output = content_tag(:crumbs, output) output when :json crumbs.map{ |crumb| render_json(crumb) }.to_json else raise NotImplementedError, "unsupported format: #{option_or_default(:format)}" end end |