Guest User

Untitled

a guest
Sep 23rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. module Helpers
  2. module Items
  3. class Nanoc::Item
  4.  
  5. # path gibt die "URL" zum Item zurück
  6. old_path = instance_method(:path)
  7.  
  8. define_method(:path) do |params = { }|
  9. # Für manche Items will ich direkt auf eine andere Seite linken
  10. return @site.items.find!(self[:forward]).path if self[:forward]
  11.  
  12. # Oder, falls nicht geforwarded, einfach den normalen path angeben
  13. old_path.bind(self).call(params)
  14. end
  15.  
  16. # Den original-Path brauch ich an manchen Stellen auch noch...
  17. define_method(:unfordwarded_path) do |params = { }|
  18. old_path.bind(self).call(params)
  19. end
  20. end
  21. end
  22. end
Add Comment
Please, Sign In to add comment