lib/crumpet/renderer.rb in crumpet-0.2.1 vs lib/crumpet/renderer.rb in crumpet-0.3.0
- old
+ new
@@ -1,13 +1,18 @@
module Crumpet
class Renderer
include ActionView::Helpers::UrlHelper
include ERB::Util
- attr_reader :options
+ attr_reader :crumbs, :options
- def initialize(options = {})
+ def self.render(crumbs, options = {})
+ new(crumbs, options).render
+ end
+
+ def initialize(crumbs, options = {})
+ @crumbs = crumbs
@options = options
end
def render
return '' if crumbs.empty? && !option_or_default(:render_when_blank)
@@ -27,13 +32,9 @@
raise NotImplementedError, "unsupported format: #{option_or_default(:format)}"
end
end
private
-
- def crumbs
- Crumpet.crumbs
- end
def render_html(crumb)
name = render_name(crumb)
item_options = build_html_options(crumb)
wrapper_options = build_wrapper_options(crumb)