diff --git a/documentation/cs/expressions.cs b/documentation/cs/expressions.cs index 3309739a..0e8da6d5 100644 --- a/documentation/cs/expressions.cs +++ b/documentation/cs/expressions.cs @@ -2,7 +2,7 @@ grade: student => if student.excellent_work "A+" else if student.okay_stuff - "B" + if student.tried_hard then "B" else "B-". else "C".. diff --git a/documentation/css/docs.css b/documentation/css/docs.css index cd45d0a8..3d11307b 100644 --- a/documentation/css/docs.css +++ b/documentation/css/docs.css @@ -1,7 +1,7 @@ body { font-size: 14px; line-height: 20px; - background: #efefef; + background: #efeff9; color: #191933; font-family: Arial, Helvetica, sans-serif; } diff --git a/documentation/index.html.erb b/documentation/index.html.erb index d571d13a..8d2086d2 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -39,7 +39,7 @@
- Disclaimer:
+ Disclaimer:
CoffeeScript is just for fun and seriously alpha. There is no guarantee,
explicit or implied, of its suitability for any purpose. That said, it
compiles into pretty-printed JavaScript (the good parts) that can pass through
diff --git a/documentation/js/expressions.js b/documentation/js/expressions.js
index b6287487..762f9720 100644
--- a/documentation/js/expressions.js
+++ b/documentation/js/expressions.js
@@ -3,7 +3,11 @@
if (student.excellent_work) {
return "A+";
} else if (student.okay_stuff) {
- return "B";
+ return if (student.tried_hard) {
+ return "B";
+ } else {
+ return "B-";
+ };
} else {
return "C";
}
diff --git a/index.html b/index.html
index 63b99d6a..99016737 100644
--- a/index.html
+++ b/index.html
@@ -26,7 +26,7 @@
- Disclaimer:
+ Disclaimer:
CoffeeScript is just for fun and seriously alpha. There is no guarantee,
explicit or implied, of its suitability for any purpose. That said, it
compiles into pretty-printed JavaScript (the good parts) that can pass through
@@ -210,7 +210,7 @@ expensive = expensive ||if student.excellent_work
"A+"
else if student.okay_stuff
- "B"
+ if student.tried_hard then "B" else "B-".
else
"C"..
@@ -219,7 +219,11 @@ eldest: if if (student.excellent_work) {
return "A+";
} else if (student.okay_stuff) {
- return "B";
+ return if (student.tried_hard) {
+ return "B";
+ } else {
+ return "B-";
+ };
} else {
return "C";
}
@@ -229,7 +233,11 @@ eldest: if this.name + " moved " + meters + "m.").
Snake: name => this.name: name.
-Snake extends new Animal()
+Snake.prototype: new Animal()
Snake.prototype.move: =>
alert("Slithering...")
super(5).
Horse: name => this.name: name.
-Horse extends new Animal()
+Horse.prototype: new Animal()
Horse.prototype.move: =>
alert("Galloping...")
super(45).
diff --git a/lib/coffee_script/nodes.rb b/lib/coffee_script/nodes.rb
index 18fbbd92..1b5d2a89 100644
--- a/lib/coffee_script/nodes.rb
+++ b/lib/coffee_script/nodes.rb
@@ -648,7 +648,7 @@ module CoffeeScript
def compile(o={})
o = super(o)
- write(o[:statement] || statement? ? compile_statement(o) : compile_ternary(o))
+ write(statement? ? compile_statement(o) : compile_ternary(o))
end
# Compile the IfNode as a regular if-else statement. Flattened chains
@@ -659,7 +659,7 @@ module CoffeeScript
if_part = "if (#{@condition.compile(o.merge(:no_paren => true))}) {\n#{Expressions.wrap(@body).compile(o)}\n#{indent}}"
return if_part unless @else_body
else_part = chain? ?
- " else #{@else_body.compile(o.merge(:statement => true, :indent => indent))}" :
+ " else #{@else_body.compile(o.merge(:indent => indent))}" :
" else {\n#{Expressions.wrap(@else_body).compile(o)}\n#{indent}}"
if_part + else_part
end