Code samples in blog posts

I was tired of trying to find a decent way of dropping code into my new blog redesign .. that wasn't heavy js with horrible css to try and override.

So I kept it simple, and have added a lovely helper method that lets me do this in my article templates (its a custom ruby publishing thing I've written).

-code_sample("Setting up the widget", 'article_1/sample.js')

Which outputs an ordered list, and link to the file for people to download or whatever .. the line indent is calculated from the source file, and added as a class to each list item so it can be formatted correctly.

This is what the output looks like when its styled on my current design refresh.

A lot simpler and easier for me to throw in whatever I like.

More by Jason Cale

View profile