Sha256: c0e5671efce1d13deb795588c3aa90230605b86c386d2555eaa169609f8fd3c2

Contents?: true

Size: 705 Bytes

Versions: 4

Compression:

Stored size: 705 Bytes

Contents

# ~*~ encoding: utf-8 ~*~
module Aladdin

  module Render

    # Keeps track of document sections and renders a navigation bar.
    class Navigation < Template

      # HAML template for navigation bar
      TEMPLATE = 'nav.haml'

      # Creates a new navigation bar.
      def initialize
        @sections = {}
      end

      # Adds a new section.
      # @param [String] heading      section heading
      # @param [String] name         anchor name
      # @return [void]
      def append(heading, name)
        @sections[name] = heading
      end

      # Renders the navigation bar in HTML.
      def render(locals={})
        super locals.merge(sections: @sections)
      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aladdin-0.0.8 lib/aladdin/render/templates/navigation.rb
aladdin-0.0.7 lib/aladdin/render/templates/navigation.rb
aladdin-0.0.6 lib/aladdin/render/templates/navigation.rb
aladdin-0.0.5 lib/aladdin/render/templates/navigation.rb