lib/gretel/trails/patches/renderer.rb in gretel-trails-0.0.2 vs lib/gretel/trails/patches/renderer.rb in gretel-trails-0.0.3
- old
+ new
@@ -10,8 +10,22 @@
alias_method_chain :parent_links_for, :trail
# Returns encoded trail for the breadcrumb.
def trail
- @trail ||= Gretel::Trails.encode(links)
+ @trail ||= begin
+ transformed_links = links.dup
+ if transform_current_path && transformed_links.any? && request
+ transformed_links.last.url = request.fullpath
+ end
+ Gretel::Trails.encode(transformed_links)
+ end
end
+
+ # Whether to set the current link path to +request.fullpath+.
+ def transform_current_path
+ return @transform_current_path if defined?(@transform_current_path)
+ @transform_current_path = true
+ end
+
+ attr_writer :transform_current_path
end
\ No newline at end of file