Skip to content

Instantly share code, notes, and snippets.

@plmrry
Last active July 13, 2016 13:06
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 plmrry/9e50004af98a3c55a3d59a616685d269 to your computer and use it in GitHub Desktop.
Save plmrry/9e50004af98a3c55a3d59a616685d269 to your computer and use it in GitHub Desktop.
Babel Standalone Template
license: gpl-3.0
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.10.3/babel.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
d3.text('script.js', function(err, source) {
var options = { presets: ['es2015'] };
var compiled = Babel.transform(source, options).code;
(new Function(compiled))();
})
</script>
</body>
const [ a, b ] = [ 'code', 'below' ];
const { c } = { c: 'change' };
const baz = ({ a, b, c }) => `Edit the ${a} ${b} to ${c} me!`;
const svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500);
svg.append("text")
.text(baz({ a, b, c }))
.attr("y", 200)
.attr("x", 120)
.style("font-size", 36)
.style("font-family", "monospace");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment