Unfancy JavaScript
Go to file
Gregory Huczynski 78e1f43b24 CS1 tagged template literals (and CS2 interpolated strings as template literals) (#4352)
* Add initial support for template literals with no
interpolation

* Change ‘unexpected string’ error message tests to
use number not identifier prefix.

Identifer prefixes are now valid as tagged
template literals

* Test tagged template literals for non-interpolated
strings and tag function.

* Tagged template literals work for pure Strings.

Pull tagged template definition up to Invocation
level in grammar, enabling chained invocation calls.

We can view a tagged template is a special form
of function call.

* Readying for StringWithInterpolations work.

* Tweaks.

* Fix style

* Pass StringWithInterpolations parameter straight
into Call constructor.

StringWithInterpolations will be output as
template literal, so already in correct form for
outputting tagged template literal.

* Strip down compileNode for StringWithInterpolations

* Done StringLiteral case for interpolated Strings

* Remove need for TemplateLiteral

* Simplify code.

* Small code tidy

* Interpolated strings now outputting as template literals.

Still needs comprehensive testing.

* Move error message tests into error_messages.coffee; remove test that is testing for a Node runtime error

* Split up tests that were testing multiple things per test, so that each test tests only one thing

* Edge cases: tagged template literals containing interpolated strings or even internal tagged template literals

* Make more concise, more idiomatic style

* Pull back extreme indentation

* Restore and fix commented-out tests

* Edge case: tagged template literal with empty string

* Only use new ES2015 interpolated string syntax if we’re inside a tagged template literal; this keeps this PR safe to merge into CoffeeScript 1.x. Remove the code from this commit to make all interpolated strings use ES2015 syntax, for CoffeeScript 2.

* Compiler now _doesn’t_ use template literals.

* Expand tagged template literal tests

* Move ‘Unexpected string’ error message tests into
tagged template literal section.

‘Unexpected string’ is not reported in these test
scenarios anymore. Instead, we error that the
prefixing literal is not a function.

* Don’t unwrap StringWithInterpolations.

Saw bug with program consisting of “#{2}” not
compiling with template literals. Root cause was
that Block.compileNode was unwrapping interpolated
string and so didn’t use compileNode logic at
StringWithInterpolations level.

* No need to bracket interpolated strings any more.

When interpolated string looks like `hello ${2}`,
no extract brackets are needed, as the `s mark the
beginning and end.

* Show html templating with tagged template literals

* Multiline should match multiline

* Comment out unnecessary `unwrap`, which is only needed for CoffeeScript 2 all-ES2015 syntax output
2016-11-18 10:25:03 -08:00
bin Moved src/*.coffee under src/coffee-script/ so that lib can be added to $NODE_PATH and only expose the top-level coffee-script namespace. Fixes #1246 2011-07-05 21:58:04 +10:00
docs Revert to http://coffeescript.org until GitHub pages supports HTTPS for custom domains (#4363) 2016-11-17 09:57:03 -08:00
documentation Revert to http://coffeescript.org until GitHub pages supports HTTPS for custom domains (#4363) 2016-11-17 09:57:03 -08:00
examples Ensure that all source files end with a single `\n` 2015-09-03 19:20:12 +02:00
lib/coffee-script CS1 tagged template literals (and CS2 interpolated strings as template literals) (#4352) 2016-11-18 10:25:03 -08:00
src CS1 tagged template literals (and CS2 interpolated strings as template literals) (#4352) 2016-11-18 10:25:03 -08:00
test CS1 tagged template literals (and CS2 interpolated strings as template literals) (#4352) 2016-11-18 10:25:03 -08:00
.gitignore ignore litcoffee files 2012-09-25 17:50:04 -05:00
.nojekyll Move v1 documentation under `docs/v1`, with `docs/index.html` symlinking to `docs/v1/index.html` (with `.nojekyll` file to hopefully make the symlink work) 2016-11-15 20:54:30 -08:00
CONTRIBUTING.md Ensure that all source files end with a single `\n` 2015-09-03 19:20:12 +02:00
Cakefile Revert to http://coffeescript.org until GitHub pages supports HTTPS for custom domains (#4363) 2016-11-17 09:57:03 -08:00
LICENSE Fixed copyright range to be updated to 2015 2015-02-08 11:28:51 -08:00
README.md Revert to http://coffeescript.org until GitHub pages supports HTTPS for custom domains (#4363) 2016-11-17 09:57:03 -08:00
bower.json CoffeeScript 1.11.1 2016-10-01 20:58:53 +02:00
package.json Revert to http://coffeescript.org until GitHub pages supports HTTPS for custom domains (#4363) 2016-11-17 09:57:03 -08:00
register.js fix auto and manual require.extensions registration; ref #3141 2013-12-08 14:19:10 -06:00
repl.js Export the CoffeeScript REPL. 2014-04-18 08:26:51 -05:00

README.md

        {
     }   }   {
    {   {  }  }
     }   }{  {
    {  }{  }  }                    _____       __  __
   { }{ }{  { }                   / ____|     / _|/ _|
 .- { { }  { }} -.               | |     ___ | |_| |_ ___  ___
(  { } { } { } }  )              | |    / _ \|  _|  _/ _ \/ _ \
|`-..________ ..-'|              | |___| (_) | | | ||  __/  __/
|                 |               \_____\___/|_| |_| \___|\___|
|                 ;--.
|                (__  \            _____           _       _
|                 | )  )          / ____|         (_)     | |
|                 |/  /          | (___   ___ _ __ _ _ __ | |_
|                 (  /            \___ \ / __| '__| | '_ \| __|
|                 |/              ____) | (__| |  | | |_) | |_
|                 |              |_____/ \___|_|  |_| .__/ \__|
 `-.._________..-'                                  | |
                                                    |_|

CoffeeScript is a little language that compiles into JavaScript.

Installation

If you have the node package manager, npm, installed:

npm install -g coffee-script

Leave off the -g if you don't wish to install globally. If you don't wish to use npm:

git clone https://github.com/jashkenas/coffeescript.git
sudo coffeescript/bin/cake install

Getting Started

Execute a script:

coffee /path/to/script.coffee

Compile a script:

coffee -c /path/to/script.coffee

For documentation, usage, and examples, see: http://coffeescript.org/

To suggest a feature or report a bug: http://github.com/jashkenas/coffeescript/issues

If you'd like to chat, drop by #coffeescript on Freenode IRC.

The source repository: https://github.com/jashkenas/coffeescript.git

Changelog: http://coffeescript.org/#changelog

Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors