Skip to content

Instantly share code, notes, and snippets.

@timwis timwis/
Last active Dec 29, 2016

What would you like to do?
Indent multi-line string

Indent multi-line string

  ${indent(JSON.stringify(data, null, 2), 2)}
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
You can’t perform that action at this time.