Class: Humpyard::UriParser::PagesUriParser

Inherits:
Object
  • Object
show all
Defined in:
lib/humpyard/uri_parser/pages_uri_parser.rb

Class Method Summary collapse

Class Method Details

.substitute(content, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/humpyard/uri_parser/pages_uri_parser.rb', line 4

def self.substitute content, options = {}
  content.gsub(/humpyard:\/\/page\/([0-9]*)/) do |uri| 
    begin
      "#{options[:prefix]}#{Page.find($1).human_url}#{options[:postfix]}"          
    rescue
      "#{options[:prefix]}#{Page.root_page.human_url}#{options[:postfix]}"  
    end
  end
end