Subscribe to the MPC blog rss feed feed-icon-14x14
 

Embedding Code Snippets in Your Blog Using Gists

Posted on 08:42PM on 04/19/2009
Tags: Gist

I'm not sure why, but I've never paid much attention to Gists. Gists are pasted code snippets hosted by GitHub. You can see them here. It's a service similar to PasteBin or one of the others, but it offers more, including versioning, branching, etc. To be honest, though, what I really like is the ability to embed a Gist into my blog, like so:

I really like this approach because it removes the requirement for syntax highlighting within the blog code. Additionally, when I update a Gist, that change is reflected on the blog.

Recently I've commited a new Ruby library called Gistr that allowed developers using Rails or Sinatra to embed Gists into their views. It's a really simple library and probably not of any great use to anyone, but I thought it was fun. It could easily be extended to add functionality to other Ruby web frameworks. Feel free if you find it useful.

The main point of this post is that maybe things like Google syntax highlighter are unecessary when you can just embed a Gist.

1 Comment (Show) (Comments are closed for this post)

Please note that I am currently unavailable for any large, long term work.