Skip to content

Instantly share code, notes, and snippets.

@FireNeslo FireNeslo/demo.es6
Last active Jan 2, 2018

What would you like to do?
Simple es6 heredoc thingy
var html = heredoc `
<h1> title</h1>
function leastSpaces(length, line) {
if(!line.length) return length
var spaces = line.match(/^\s+/).pop().length
return spaces < length ? spaces : length
function heredoc(strings) {
var lines = strings.join('').split(/\r?\n/)
var spaces = lines.reduce(leastSpaces, Infinity)
return => line.substring(spaces)).join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.