module Toolsmith
  module Views
    class PageHeader < Base
      attr_accessor :title, :subtitle

      def initialize(context, title, subtitle=nil)
        super(context)

        @title = title
        @subtitle = subtitle
      end

      def button(options)
        [:title, :icon, :path].each { |param| missing_parameter(param, options) }
        buttons << options
      end

      def button_markup(options)
        anchor_options = options.fetch(:anchor, {})
        context.link_to options[:path], anchor_options.merge(class: "btn"), title: options[:title] do
          content_tag :i, "", class: "icon-#{options[:icon]}"
        end
      end

      def buttons
        @buttons ||= []
      end

      def full_title
        subtitle ? ERB::Util.h(title) + content_tag(:small, subtitle) : ERB::Util.h(title)
      end

      def to_s
        content_tag(:h1) do
          content_tag(:div, nil, class: "pull-right") do
            content_tag(:div, class: "btn-group") do
              buttons.map do |button|
                button_markup(button)
              end.inject("".html_safe, :+)
            end
          end + full_title
        end
      end
    end
  end
end
module Toolsmith
  module Views
    class PageHeader < Base
      attr_accessor :title, :subtitle

      def initialize(context, title, subtitle=nil)
        super(context)

        @title = title
        @subtitle = subtitle
      end

      def button(options)
        [:title, :icon, :path].each { |param| missing_parameter(param, options) }
        buttons << options
      end

      def button_markup(options)
        anchor_options = options.fetch(:anchor, {})
        context.link_to options[:path], anchor_options.merge(class: "btn"), title: options[:title] do
          content_tag :i, "", class: "icon-#{options[:icon]}"
        end
      end

      def buttons
        @buttons ||= []
      end

      def full_title
        subtitle ? "#{ERB::Util.h(title)} #{content_tag(:small, self.subtitle)}".html_safe : ERB::Util.h(title)
      end

      def to_s
        content_tag(:h1) do
          content_tag(:div, nil, class: "pull-right") do
            content_tag(:div, class: "btn-group") do
              buttons.map do |button|
                button_markup(button)
              end.inject("".html_safe, :+)
            end
          end + full_title
        end
      end
    end
  end
end
Update page header to include a space inbetween the subtitle and title.
Update page header to include a space inbetween the subtitle and title.
