From c1309e12f771529f70d942698456ec854eb89876 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Wed, 25 Apr 2012 14:37:05 -0400 Subject: [PATCH] Fixes #2209 -- document heredocs as 'block strings' --- documentation/index.html.erb | 20 ++++++++++---------- index.html | 34 +++++++++++----------------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/documentation/index.html.erb b/documentation/index.html.erb index 1dceaae4..16ae23e8 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -62,8 +62,8 @@ Embedded JavaScript Switch and Try/Catch Chained Comparisons - String Interpolation, Heredocs, and Block Comments - Extended Regular Expressions + String Interpolation, Block Strings, and Block Comments + Block Regular Expressions Cake, and Cakefiles "text/coffeescript" Script Tags Books, Screencasts, Examples and Resources @@ -837,7 +837,7 @@ Expressions

- String Interpolation, Heredocs, and Block Comments + String Interpolation, Block Strings, and Block Comments Ruby-style string interpolation is included in CoffeeScript. Double-quoted strings allow for interpolated values, using #{ ... }, and single-quoted strings are literal. @@ -848,30 +848,30 @@ Expressions

<%= code_for('strings', 'mobyDick') %>

- Heredocs can be used to hold formatted or indentation-sensitive text + Block strings can be used to hold formatted or indentation-sensitive text (or, if you just don't feel like escaping quotes and apostrophes). The - indentation level that begins the heredoc is maintained throughout, so + indentation level that begins the block is maintained throughout, so you can keep it all aligned with the body of your code.

<%= code_for('heredocs', 'html') %>

- Double-quoted heredocs, like double-quoted strings, allow interpolation. + Double-quoted block strings, like other double-quoted strings, allow interpolation.

Sometimes you'd like to pass a block comment through to the generated JavaScript. For example, when you need to embed a licensing header at - the top of a file. Block comments, which mirror the syntax for heredocs, + the top of a file. Block comments, which mirror the syntax for block strings, are preserved in the generated code.

<%= code_for('block_comment') %>

- Extended Regular Expressions - Similar to "heredocs" and "herecomments", CoffeeScript supports "heregexes" — + Block Regular Expressions + Similar to block strings and comments, CoffeeScript supports block regexes — extended regular expressions that ignore internal whitespace and can contain comments and interpolation. Modeled after Perl's /x modifier, CoffeeSctipt's - heregexes are delimited by /// and go a long way towards making complex + block regexes are delimited by /// and go a long way towards making complex regular expressions readable. To quote from the CoffeeScript source:

<%= code_for('heregexes') %> diff --git a/index.html b/index.html index f02f9bba..8c2e4945 100644 --- a/index.html +++ b/index.html @@ -39,8 +39,8 @@ Embedded JavaScript Switch and Try/Catch Chained Comparisons - String Interpolation, Heredocs, and Block Comments - Extended Regular Expressions + String Interpolation, Block Strings, and Block Comments + Block Regular Expressions Cake, and Cakefiles "text/coffeescript" Script Tags Books, Screencasts, Examples and Resources @@ -1463,8 +1463,6 @@ tom.move() Animal = (function() { - Animal.name = 'Animal'; - function Animal(name) { this.name = name; } @@ -1481,8 +1479,6 @@ Snake = (function(_sup __extends(Snake, _super); - Snake.name = 'Snake'; - function Snake() { return Snake.__super__.constructor.apply(this, arguments); } @@ -1500,8 +1496,6 @@ Horse = (function(_sup __extends(Horse, _super); - Horse.name = 'Horse'; - function Horse() { return Horse.__super__.constructor.apply(this, arguments); } @@ -1528,8 +1522,6 @@ tom.move(); Animal = (function() { - Animal.name = 'Animal'; - function Animal(name) { this.name = name; } @@ -1546,8 +1538,6 @@ Snake = (function(_super) { __extends(Snake, _super); - Snake.name = 'Snake'; - function Snake() { return Snake.__super__.constructor.apply(this, arguments); } @@ -1565,8 +1555,6 @@ Horse = (function(_super) { __extends(Horse, _super); - Horse.name = 'Horse'; - function Horse() { return Horse.__super__.constructor.apply(this, arguments); } @@ -1922,7 +1910,7 @@ healthy = (200 > cholesterol && cholesterol > 60);

- String Interpolation, Heredocs, and Block Comments + String Interpolation, Block Strings, and Block Comments Ruby-style string interpolation is included in CoffeeScript. Double-quoted strings allow for interpolated values, using #{ ... }, and single-quoted strings are literal. @@ -1970,9 +1958,9 @@ mobyDick = run: mobyDick

- Heredocs can be used to hold formatted or indentation-sensitive text + Block strings can be used to hold formatted or indentation-sensitive text (or, if you just don't feel like escaping quotes and apostrophes). The - indentation level that begins the heredoc is maintained throughout, so + indentation level that begins the block is maintained throughout, so you can keep it all aligned with the body of your code.

html = """
@@ -1989,12 +1977,12 @@ html = &q
 html = "\n  cup of coffeescript\n";
 ;alert(html);'>run: html

- Double-quoted heredocs, like double-quoted strings, allow interpolation. + Double-quoted block strings, like other double-quoted strings, allow interpolation.

Sometimes you'd like to pass a block comment through to the generated JavaScript. For example, when you need to embed a licensing header at - the top of a file. Block comments, which mirror the syntax for heredocs, + the top of a file. Block comments, which mirror the syntax for block strings, are preserved in the generated code.

###
@@ -2013,11 +2001,11 @@ html = "\n  cup of coffeescript\n";
 
     

- Extended Regular Expressions - Similar to "heredocs" and "herecomments", CoffeeScript supports "heregexes" — + Block Regular Expressions + Similar to block strings and comments, CoffeeScript supports block regexes — extended regular expressions that ignore internal whitespace and can contain comments and interpolation. Modeled after Perl's /x modifier, CoffeeSctipt's - heregexes are delimited by /// and go a long way towards making complex + block regexes are delimited by /// and go a long way towards making complex regular expressions readable. To quote from the CoffeeScript source:

OPERATOR = /// ^ (
@@ -2956,7 +2944,7 @@ task('build:parser