Sha256: a15b405d4a4a484d8711948fcd1b02a2443ced5c3fdb44d0ef8bb7b5acb03dee
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'loaf/configuration' module Loaf module Helpers class_eval do define_method :config do |options| Loaf.config end end # Adds breadcrumbs in a view def add_breadcrumb(name, url=nil) _breadcrumbs.push(name, url) end def breadcrumbs(options={}, &block) #builder = Loaf::Builder.new(options) options = config.merge(options) _breadcrumbs.each do |crumb| name = if crumb.name formatted = options[:capitalize] ? crumb.name.capitalize : crumb.name truncate(formatted, :length => options[:crumb_length]) else '[name-error]' end url = url_for _process_url_for(crumb.url) styles = ( request.request_uri.split('?')[0] == url ? "#{options[:style_classes]}" : '' ) block.call(name, url, styles) end end private def _process_url_for(url) if url.is_a?(String) || url.is_a?(Symbol) return send url else return url end end end # Helpers end # Loaf
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loaf-0.1.1 | lib/loaf/helpers.rb |