mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
got comments within object and array literals working out
This commit is contained in:
@@ -423,7 +423,10 @@ module CoffeeScript
|
||||
o = super(o)
|
||||
indent = o[:indent]
|
||||
o[:indent] += TAB
|
||||
props = @properties.map {|p| o[:indent] + p.compile(o) }.join(",\n")
|
||||
props = @properties.map { |prop|
|
||||
joiner = prop == @properties.last ? '' : prop.is_a?(CommentNode) ? "\n" : ",\n"
|
||||
o[:indent] + prop.compile(o) + joiner
|
||||
}.join('')
|
||||
write("{\n#{props}\n#{indent}}")
|
||||
end
|
||||
end
|
||||
@@ -438,8 +441,12 @@ module CoffeeScript
|
||||
|
||||
def compile(o={})
|
||||
o = super(o)
|
||||
objects = @objects.map {|obj| obj.compile(o) }.join(', ')
|
||||
write("[#{objects}]")
|
||||
objects = @objects.map { |obj|
|
||||
joiner = obj.is_a?(CommentNode) ? "\n#{o[:indent] + TAB}" : obj == @objects.last ? '' : ', '
|
||||
obj.compile(o.merge(:indent => o[:indent] + TAB)) + joiner
|
||||
}.join('')
|
||||
ending = objects.include?("\n") ? "\n#{o[:indent]}]" : ']'
|
||||
write("[#{objects}#{ending}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user