Sha256: 12440a873c3751beea1e000fe43916b94ab9043be5851fefe3cbd395a8c700d1
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require "i18n" unless defined?(I18n) require "breadcrumbs/render" require "breadcrumbs/action_controller_ext" if defined?(ActionController) class Breadcrumbs attr_accessor :items def initialize # :nodoc: self.items = [] end # Add a new breadcrumbs. # # breadcrumbs.add "Home" # breadcrumbs.add "Home", "/" # breadcrumbs.add "Home", "/", :class => "home" # # If you provide a symbol as text, it will try to # find it as I18n scope. # def add(text, url = nil, options = {}) items << [translate(text), url, options] end # Render breadcrumbs using the specified format. # Use HTML lists by default, but can be plain links. # # breadcrumbs.render # breadcrumbs.render(:format => :inline) # breadcrumbs.render(:format => :inline, :separator => "|") # breadcrumbs.render(:format => :list) # breadcrumbs.render(:id => "breadcrumbs") # breadcrumbs.render(:class => "breadcrumbs") # def render(options = {}) if options[:format] == :inline Breadcrumbs::Render::Inline.new(self, options).render else Breadcrumbs::Render::List.new(self, options).render end end alias :<< :add def translate(scope) # :nodoc: text = I18n.t(scope, :scope => :breadcrumbs, :raise => true) rescue nil text ||= I18n.t(scope, :default => scope) text end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
breadcrumbs-0.1.0 | lib/breadcrumbs.rb |