Skip to content

Commit

Permalink
Make sure if/else if/else parts line up in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 6, 2013
1 parent 46d23f2 commit cebaaef
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/opal/parser.rb
Expand Up @@ -1701,9 +1701,19 @@ def process_if(sexp, level)
indent { result.push(f(@indent, sexp), process(truthy, :stmt)) } if truthy

outdent = @indent
indent { result.push(f("\n#{outdent}} else {\n#@indent", sexp), process(falsy, :stmt)) } if falsy

result << f("\n#@indent}", sexp)
if falsy
if falsy[0] == :if
result.push(f("\n#{outdent}} else "), process(falsy, :stmt))
else
indent {
result.push(f("\n#{outdent}} else {\n#@indent", sexp), process(falsy, :stmt))
}
result << f("\n#@indent}", sexp)
end
else
result << f("\n#@indent}", sexp)
end

if returnable
result.unshift f("(function() { ", sexp)
Expand Down

0 comments on commit cebaaef

Please sign in to comment.