Created
November 13, 2013 22:33
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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