Update template_handler.rb

jRuby seems to have some issues with providing captures to function calls within the second argument of gsub, switching the replacement procedure to a block solved the issue. Also used the Pathname object to return a clean absolute path.