module Kin module Nav module Formatters ## # Receives a nav instance and transforms it into HTML. # # @see Kin::Nav::Helper#display_navigation # class Basic include Merb::Helpers::Tag ## # Creates a new BasicFormatter instance. # # @param [Kin::Nav::Menu] nav # An instance of a Menu to be rendered as HTML. # @param [#controller_name, #action_name] controller # An object which behaves like a controller. # @param [Hash] options # A hash of options for customising the menu. See # Kin::Nav::Helper#display_navigation. # # @api public # def initialize(nav, controller, options) @nav = nav @current = nav.active_item(controller) @resource = options[:resource] @inject = options.fetch(:inject, {}) @guards = options.fetch(:guard, {}) # Escape injected content. @inject.each do |item_id, contents| contents = Array(contents) contents.map! { |v| Merb::Parse.escape_xml(v) } @inject[item_id] = contents end end ## # Transforms the menu given to +initialize+ into a string containing # HTML. # # @return [String] # HTML containing the rendered menu. A collection of
  • elements # contained in a