Module: Hensel::Helpers::SinatraHelpers

Defined in:
lib/hensel/helpers/sinatra_helpers.rb

Instance Method Summary collapse

Instance Method Details

#__henselObject



4
5
6
# File 'lib/hensel/helpers/sinatra_helpers.rb', line 4

def __hensel
  @__hensel ||= settings.respond_to?(:hensel) ? settings.hensel : {}
end


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/hensel/helpers/sinatra_helpers.rb', line 8

def breadcrumbs
  @__breadcrumbs ||=
    begin
      builder = Hensel::Builder.new(__hensel[:builder_options] || {})
      renderer = __hensel[:renderer]
      if renderer && renderer.instance_of?(Proc)
        builder.singleton_class.send(:define_method, :render) do |&block|
          if block.instance_of?(Proc)
            super(&block)
          else
            concatenated_items =
              map_items do |item|
                renderer.arity.zero? ? item.instance_eval(&renderer) : renderer.call(item)
              end.join(Hensel.configuration.indentation? ? "\n" : "")
            (Hensel.configuration.parent_element, concatenated_items, options)
          end
        end
      end
      builder
    end
end