moonscript/spec/helpers.moon
2014-06-07 00:04:26 -07:00

10 lines
229 B
Plaintext

-- remove front indentation from a multiline string, making it suitable to be
-- parsed
unindent = (str) ->
indent = str\match "^%s+"
return str unless indent
(str\gsub("\n#{indent}", "\n")\gsub "%s+$", "")
{ :unindent }