app/helpers/trestle/container_helper.rb in trestle-0.9.5 vs app/helpers/trestle/container_helper.rb in trestle-0.9.6

- old
+ new

@@ -4,21 +4,29 @@ context = Context.new(self) content = capture(context, &block) content_tag(:div, class: "main-content-container") do concat content_tag(:div, content, class: "main-content") - concat content_tag(:aside, context.sidebar, class: "main-content-sidebar") unless context.sidebar.blank? + concat context.sidebar if context.sidebar end end class Context def initialize(template) @template = template end - def sidebar(&block) - @sidebar = @template.capture(&block) if block_given? - @sidebar + def sidebar(options={}, &block) + if block_given? + @sidebar = @template.content_tag(:aside, default_sidebar_options.merge(options), &block) + nil + else + @sidebar + end + end + + def default_sidebar_options + Trestle::Options.new(class: ["main-content-sidebar"]) end end end end