module BreadcrumbHelper def breadcrumb(options = {}) options = {action: @action}.merge options capture_haml do haml_tag :h1 do unless @result.present? haml_concat "Erreur dans le BreadcrumbHelper" else if options[:custom_last_item].present? haml_concat(link_to @result[:first][:name], @result[:first][:link]) haml_tag(:span) { haml_concat(link_to @result[:second][:name], @result[:second][:link]) } if @result[:second].present? case options[:action] when :new haml_tag(:span) {haml_concat("Création #{@result[:first][:name].singularize.downcase}")} when :edit haml_tag(:span) {haml_concat('Modification')} when :index haml_tag(:span) {haml_concat('Liste')} end haml_tag(:span) {haml_concat(options[:custom_last_item])} else @result[:second].present? ? haml_concat(link_to @result[:first][:name], @result[:first][:link]) : haml_concat( @result[:first][:name]) haml_tag(:span) { haml_concat( @result[:second][:name]) } if @result[:second].present? end end end end end end