Latte is a superset of JavaScript with lots of useful extensions. Get the power of CoffeeScript, but keep the syntax you know and love.
Latte is available on npm (browser version coming soon). Install globally:
npm install -g latte
...or locally:
npm install --save-dev latte
On the command line:
$ latte --help Latte.js compiler. Usage: latte [options] [--] files... Options: -c, --compile Compile input files. If not specified, evaluates the files. -o, --output Output directory, to be used with --compile. --version Show version
With Grunt:
grunt.loadNpmTasks('latte'); grunt.initConfig({ latte: { client: { inputDir: 'src/client', outputDir: 'lib/client' } } });
Latte adds support for the ES6 Let Statement
Latte adds support for ES6 array comprehensions.
Anyone who's done serious work in Node knows that async can be a pain. Latte supports monad constructs to make life simpler again.
Latte's monad construct is inspired by do-notation in Haskell. Monads may sound scary, but really they're just promises, and with latte you can write async code as if it was synchronous.
jQuery's ajax() returns a promise, so we can use do-notation to make this code look synchronous.
do { var result = << jQuery.get('http://example.com'); alert(result); }
The bind operator (<<) is the magic which makes this work. It's a unary operator, which takes any value. If that value evaluates to a promise (an object with a then() method), execution will yield at that point, and resume when the promise is resolved. The value of the expression will then be the resoved value of the promise.
This expression can be used anywhere inside a do {} block. So for the jQuery example above, we could have wrote:
do { alert(<< jQuery.get('http://example.com')); }
Latte is at an early stage of development, and I'm keen to hear any thoughts, suggestions, issues, criticisms, and I welcome contributions!