Github Gist Short Codes for Silverstripe CMS

Gists provide a beautiful way of including formatted source code on a web page. The only thing you need to do is to embed the JavaScript described here: Github embedded Gists

Due to security reasons, content management systems like Silverstripe prevent the use of JavaScript in content editing. To enable Gist including I added a GithubGist short code to our Silverstripe analogous to YouTube Short Codes 

The following code snippets are the result of adding them to your Silverstripe installation.

The function used to process the template:

Then we need a template for the JavaScript part of the Gist in themes/mytheme/Includes:

To make the GithubGist short code available we have to add the following code to our _config.php:

Finally you can include a Gist by adding [GithubGist id=4655825 /] to your content. Don't forget to call yoursite/yourpage?flush=1 to reload.