indent = function(string, indents) {
  indents = (new Array(indents)).join('  ')
  return string.replace(/^/gm, function(){ return indents })
...

JavaScript indent string

by Tj Holowaychuk, April 24, 2009 16:06, 4 refactorings, tagged with indent

Cleaner way?

F1e3ab214a976a39cfd713bc93deb10f Talk