From b743e3219a219b60b420ebc2c4d7f6d1a614d329 Mon Sep 17 00:00:00 2001
From: Jeremy Ashkenas
CoffeeScript is a little language that compiles into JavaScript. Think
of it as JavaScript's less ostentatious kid brother — the same genes,
- the same accent, but a different sense of style. Apart from a handful of
+ roughly the same height, but a different sense of style. Apart from a handful of
bonus goodies, statements in CoffeeScript correspond one-to-one with their
equivalent in JavaScript, it's just another way of saying it.
Try/Catch/Finally
Multiline Strings
+ Change Log
+ The CoffeeScript compiler is written in pure Ruby, and is available + as a Ruby Gem. +
-sudo gem install coffee-script+gem install coffee-script
Installing the gem provides the coffee-script command, which can @@ -339,7 +345,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js
Switch/Case/Else Switch statements in JavaScript are rather broken. You can only - do string comparisons, and need to remember to break at the end of + do comparisons based on string equality, and need to remember to break at the end of every case statement to avoid accidentally falling through to the default case. CoffeeScript compiles switch statements into JavaScript if-else chains, allowing you to @@ -352,7 +358,7 @@ coffee-script --print app/scripts/*.cs > concatenation.js
Try/Catch/Finally Try/catch statements are just about the same as JavaScript (although - they work as expressions). No braces required. + they work as expressions).
<%= code_for('try') %> @@ -361,6 +367,13 @@ coffee-script --print app/scripts/*.cs > concatenation.js Multiline strings are allowed in CoffeeScript. <%= code_for('strings', 'moby_dick') %> + ++ 0.1.0 + Initial CoffeeScript release. +
diff --git a/index.html b/index.html index a34ac81d..ff9087fe 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@CoffeeScript is a little language that compiles into JavaScript. Think of it as JavaScript's less ostentatious kid brother — the same genes, - the same accent, but a different sense of style. Apart from a handful of + roughly the same height, but a different sense of style. Apart from a handful of bonus goodies, statements in CoffeeScript correspond one-to-one with their equivalent in JavaScript, it's just another way of saying it.
@@ -58,6 +58,7 @@ Switch/Case/Else+ The CoffeeScript compiler is written in pure Ruby, and is available + as a Ruby Gem. +
-sudo gem install coffee-script+gem install coffee-script
Installing the gem provides the coffee-script command, which can @@ -654,7 +660,7 @@ return [document.title, "Hello JavaScript"].join(": ");
Switch/Case/Else Switch statements in JavaScript are rather broken. You can only - do string comparisons, and need to remember to break at the end of + do comparisons based on string equality, and need to remember to break at the end of every case statement to avoid accidentally falling through to the default case. CoffeeScript compiles switch statements into JavaScript if-else chains, allowing you to @@ -690,7 +696,7 @@ return [document.title, "Hello JavaScript"].join(": ");
Try/Catch/Finally Try/catch statements are just about the same as JavaScript (although - they work as expressions). No braces required. + they work as expressions).
try all_hell_breaks_loose() @@ -733,6 +739,13 @@ to interest me on shore, I thought I would sail \ about a little and see the watery part of the \ world..."; ;alert(moby_dick);'>run: moby_dick
+ 0.1.0 + Initial CoffeeScript release. +
diff --git a/lib/coffee_script/nodes.rb b/lib/coffee_script/nodes.rb index 38fac8bc..07603d38 100644 --- a/lib/coffee_script/nodes.rb +++ b/lib/coffee_script/nodes.rb @@ -507,7 +507,7 @@ module CoffeeScript return_result = "\n#{o[:indent]}#{return_result}" if @filter body = CallNode.new(ValueNode.new(LiteralNode.new(rvar), [AccessorNode.new('push')]), [@body]) - body = IfNode.new(@filter, body, nil, :statement) + body = IfNode.new(@filter, body, nil, :statement => true) save_result = '' suffix = '' end diff --git a/test/fixtures/execution/array_comprehension.cs b/test/fixtures/execution/array_comprehension.cs new file mode 100644 index 00000000..378d8f7e --- /dev/null +++ b/test/fixtures/execution/array_comprehension.cs @@ -0,0 +1,4 @@ +nums: n * n for n in [1, 2, 3] if n % 2 aint 0. +result: n * 2 for n in nums. + +print(result.join(',') is '2,18') \ No newline at end of file diff --git a/test/fixtures/execution/array_comprehension.js b/test/fixtures/execution/array_comprehension.js new file mode 100644 index 00000000..5bdaeee9 --- /dev/null +++ b/test/fixtures/execution/array_comprehension.js @@ -0,0 +1,21 @@ +(function(){ + var nums; + var a = [1, 2, 3]; + var d = []; + for (var b=0, c=a.length; b