Skip to content

Instantly share code, notes, and snippets.

@colllin
Last active December 7, 2020 10:02
Show Gist options
  • Save colllin/992729 to your computer and use it in GitHub Desktop.
Save colllin/992729 to your computer and use it in GitHub Desktop.
How to use UrlSpoiler to preview Gists
// 1 - load the partial via ajax and append in the desired location
$.get('http://urlspoiler.herokuapp.com/gists?id=992729&format=html', function(data){
$('body').append($(data));
});
// 2 - load the gist in an iframe
var iframe = document.createElement('iframe');
iframe.src = 'http://urlspoiler.herokuapp.com/gists?id=992729&file=examples.js';
iframe.width = "500px";
iframe.height = "200px";
iframe.setAttribute('style', "border:none;");
document.body.appendChild( iframe );

GET http://urlspoiler.herokuapp.com/gists?id=required&file=optional&format=optional

id parameter (required)

id=<the ID of the gist>

  • Extract the ID from a gist url: https://gist.github.com/<id>

file parameter (optional)

file=<the filename with extension>

  • By default, all of the files in the gist will be rendered.
  • If you only want to render one file, then specify the file=<filename> parameter.
  • Extract the filename from a gist url: https://gist.github.com/<id>#file_<filename>

format parameter (optional)

format=iframe (default)

  • The gist is rendered within a full html document. Use it as the src of an iframe.

format=html

  • Get the gist as an html snippet, then inject it anywhere you want.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment