From d7480bbfdd8cd826cd9cf3b8d8c7ca835bf31d34 Mon Sep 17 00:00:00 2001
From: Paul McKellar
Date: Thu, 27 Oct 2011 13:58:59 -0700
Subject: [PATCH 1/2] add shorthand to coffeescript reference docs
---
documentation/coffee/objects_shorthand.coffee | 5 +++++
documentation/index.html.erb | 5 +++++
documentation/js/objects_shorthand.js | 13 +++++++++++++
3 files changed, 23 insertions(+)
create mode 100644 documentation/coffee/objects_shorthand.coffee
create mode 100644 documentation/js/objects_shorthand.js
diff --git a/documentation/coffee/objects_shorthand.coffee b/documentation/coffee/objects_shorthand.coffee
new file mode 100644
index 0000000000..ce5d709ab1
--- /dev/null
+++ b/documentation/coffee/objects_shorthand.coffee
@@ -0,0 +1,5 @@
+salary = 50
+name = "Joe"
+dept = "Accounting"
+employee = {salary, name, dept}
+output = "#{employee.name} works in #{employee.dept}"
diff --git a/documentation/index.html.erb b/documentation/index.html.erb
index 522ad10849..3783b9d71b 100644
--- a/documentation/index.html.erb
+++ b/documentation/index.html.erb
@@ -418,6 +418,11 @@ Expressions
about it (say, when using jQuery).
<%= code_for('objects_reserved') %>
+
+ CoffeeScript has a shortcut for creating objects when you want the object name
+ to be set based on a variable of the same name.
+
+ <%= code_for('objects_shorthand') %>
diff --git a/documentation/js/objects_shorthand.js b/documentation/js/objects_shorthand.js
new file mode 100644
index 0000000000..cf2681d5fe
--- /dev/null
+++ b/documentation/js/objects_shorthand.js
@@ -0,0 +1,13 @@
+var dept, employee, name, output, salary;
+
+salary = 50;
+name = "Joe";
+dept = "Accounting";
+
+employee = {
+ salary: salary,
+ name: name,
+ dept: dept
+};
+
+output = "" + employee.name + " works in " + employee.dept;
From 0fc78f42acb2e3c265cb6c6f2e5e22b24c9dd334 Mon Sep 17 00:00:00 2001
From: Paul McKellar
Date: Sun, 1 Jul 2012 14:41:20 -0700
Subject: [PATCH 2/2] clarify key and object terminology for CS shorthand
method
---
documentation/index.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/documentation/index.html.erb b/documentation/index.html.erb
index 3783b9d71b..e31a205a8d 100644
--- a/documentation/index.html.erb
+++ b/documentation/index.html.erb
@@ -419,8 +419,8 @@ Expressions
<%= code_for('objects_reserved') %>
- CoffeeScript has a shortcut for creating objects when you want the object name
- to be set based on a variable of the same name.
+ CoffeeScript has a shortcut for creating objects when you want the key
+ to be set with a variable of the same name.
<%= code_for('objects_shorthand') %>