Created
October 1, 2008 20:26
-
-
Save paul/14183 to your computer and use it in GitHub Desktop.
This file contains 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
# Turn [[WikiLinks]] into internal links. | |
# add the `wikiwords` filter to your list of filters, then you can write | |
# links to other pages in your webby app like this [[OtherPage]] and it will | |
# automatically link that to "/OtherPage.html" | |
module WikiLinkHelper | |
def linkify_bracketed_phrases(string) | |
string.gsub(/\[\[([^\]]+)\]\]/) do | |
begin | |
link_to_page($1) | |
rescue ::Webby::Error => e | |
"<a class=\"missing internal\">#{$1}</a>" | |
end | |
end | |
end | |
end | |
Webby::Helpers.register(WikiLinkHelper) | |
Webby::Filters.register :wikiwords do |input, cursor| | |
cursor.renderer.linkify_bracketed_phrases(input) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment