Skip to content

Instantly share code, notes, and snippets.

@paul
Created October 1, 2008 20:26
Show Gist options
  • Save paul/14183 to your computer and use it in GitHub Desktop.
Save paul/14183 to your computer and use it in GitHub Desktop.
# 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