Pygmentize Example

Pygmentize is a fantastic gem for syntax highlighting. It's super easy to get going, even on Heroku! If you're using Heroku, be sure you use the Cedar Stack.

The source for this little is below. Very meta, I know. See the full project on GitHub. This fun example is brought to you by Sam Soffes.

Sinatra App

get '/' do
  @gemfile = Pygmentize.process(File.open('Gemfile', 'r').read, :ruby)
  @source = Pygmentize.process(File.open(__FILE__, 'r').read, :ruby)
  @config = Pygmentize.process(File.open('config.ru', 'r').read, :ruby)
  erb :index
end

Gemfile

source 'http://rubygems.org'

gem 'sinatra'
gem 'pygmentize'

config.ru

require 'rubygems'
require 'bundler'
Bundler.require

require './main'
run Sinatra::Application