Skip to content

Instantly share code, notes, and snippets.

@jsvine
Created November 13, 2013 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsvine/7457719 to your computer and use it in GitHub Desktop.
Save jsvine/7457719 to your computer and use it in GitHub Desktop.
A bare-bones helper for creating simple demos/tutorials. See example usage here: http://www.jsvine.com/gmap-button/demo/
var exemplify = function (fn, code_el) {
fn.call(fn);
var str = fn.toString();
var lines = str.split("\n").slice(1, -1);
var start_index = lines[0].match(/[^\s].*$/).index;
var trimmed = lines.map(function (x) {
return x.slice(start_index);
}).join("\n");
code_el.innerHTML = trimmed;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment