Created
April 4, 2012 18:12
-
-
Save agross/2304377 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helpers | |
module Items | |
class Nanoc::Item | |
# path gibt die "URL" zum Item zurück | |
old_path = instance_method(:path) | |
define_method(:path) do |params = { }| | |
# Für manche Items will ich direkt auf eine andere Seite linken | |
return @site.items.find!(self[:forward]).path if self[:forward] | |
# Oder, falls nicht geforwarded, einfach den normalen path angeben | |
old_path.bind(self).call(params) | |
end | |
# Den original-Path brauch ich an manchen Stellen auch noch... | |
define_method(:unfordwarded_path) do |params = { }| | |
old_path.bind(self).call(params) | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helpers | |
module Items | |
class Nanoc::Item | |
alias_method :old_path, :path | |
def path(params = { }) | |
return @site.items.find!(self[:forward]).path if self[:forward] | |
old_path(params) | |
end | |
end | |
end | |
end | |
### | |
Captain! We’ve been hit! | |
=== MESSAGE: | |
SystemStackError: stack level too deep | |
=== COMPILATION STACK: | |
(empty) | |
=== BACKTRACE: | |
0. somewhere/tmp/gems/ruby/1.9.1/gems/haml-3.1.4/lib/haml/engine.rb:191 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gerade probiert, leider ohne Erfolg. Ich glaube ich verabschiede mich vom Monkey Patching für dieses Problem und erzeuge einfach eine neue Methode
url
.