Skip to content

Instantly share code, notes, and snippets.

@timwis timwis/README.md
Last active Dec 29, 2016

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

Indent multi-line string

`
<div>
  ${indent(JSON.stringify(data, null, 2), 2)}
</div>
`
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.