Share Sandcastle Examples Easily with GitHub Gists


Starting with Cesium 1.21 on May 2, Sandcastle now integrates with the GitHub API for importing and exporting code examples.

There are two new buttons in the Sandcastle toolbar: Share and Import Gist.

To share code you’ve written in Sandcastle, just click the Share button and copy the link. When you click Share, the code is POSTed to an anonymous GitHub Gist.

When someone visits the link, Sandcastle loads and runs the code example, for example, visit:

You’ll notice the query parameter gist, which is the ID to the actual GitHub Gist that is loaded into Sandcastle.

Existing Gists, like, can also be imported into Sandcastle. Just paste in the whole link of the Gist or just the Gist’s ID (like in the screenshot below) to import.

Be sure to use this feature for including a code example when submitting an issue to the Cesium GitHub repo.

If you can’t wait for Cesium 1.21, check this out right now using the hosted version of Sandcastle from the master branch on GitHub thanks to Cesium’s new Continuous Integration.