lib/loaf/view_extensions.rb in loaf-0.7.0 vs lib/loaf/view_extensions.rb in loaf-0.8.0

- old
+ new

@@ -1,16 +1,15 @@ # frozen_string_literal: true require_relative 'breadcrumb' require_relative 'crumb' -require_relative 'crumb_formatter' require_relative 'options_validator' +require_relative 'translation' module Loaf # A mixin to define view extensions module ViewExtensions - include Loaf::CrumbFormatter include Loaf::OptionsValidator def initialize(*) @_breadcrumbs ||= [] super @@ -49,11 +48,11 @@ return enum_for(:breadcrumb_trail) unless block_given? valid?(options) options = Loaf.configuration.to_hash.merge(options) _breadcrumbs.each do |crumb| - name = format_name(crumb.name, options) + name = title_for(crumb.name) path = url_for(_expand_url(crumb.url)) current = current_crumb?(path, crumb.match) yield(Loaf::Breadcrumb[name, path, current]) end @@ -104,9 +103,18 @@ raise ArgumentError, "Unknown `:#{pattern}` match option!" end end private + + # Find title translation for a crumb name + # + # @return [String] + # + # @api private + def title_for(name) + Translation.find_title(name) + end # Expand url in the current context of the view # # @api private def _expand_url(url)