`
<div>
${indent(JSON.stringify(data, null, 2), 2)}
</div>
`
Last active
December 29, 2016 12:33
-
-
Save timwis/99d65f244ecb6b97f01b3a9c93b6b91d to your computer and use it in GitHub Desktop.
Indent multi-line string
This file contains hidden or 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
function indent (str, spaces) { | |
const indent = ' '.repeat(spaces) | |
return str.split('\n').map((line) => indent + line).join('\n') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment