@@ -5,13 +5,10 @@ compiler to PHP.
55
66## Status
77
8- CoffeeScript version ** 1.1 .1** has been fully ported over (see
8+ CoffeeScript version ** 1.3 .1** has been fully ported over (see
99[ tags] ( http://github.com/alxlit/coffeescript-php/tags ) ). Compiled code nearly
10- matches the reference 100%, except for the occasional extra newline. Tons of
11- ` E_STRICT ` problems.
12-
13- Work towards porting version 1.3.1 and making it ` E_STRICT ` is taking place
14- on the master branch.
10+ matches the reference 100%, except for [ #11 ] ( https://github.com/alxlit/coffeescript-php/issues/11 )
11+ (a good thing).
1512
1613## Requirements
1714
@@ -22,7 +19,6 @@ PHP 5.3+ (uses namespaces, anonymous functions).
2219It's recommended that you use [ Composer] ( http://getcomposer.org ) to install
2320and autoload CoffeeScript. Alternatively you can load it manually:
2421
25-
2622``` php
2723<?php
2824
@@ -36,17 +32,20 @@ CoffeeScript\Init::load();
3632
3733## Usage
3834
39- At the moment the API is pretty basic. It'll probably be expanded a bit in the
40- future .
35+ The API is really basic (single ` compile ` function). I don't plan on expanding
36+ it further (keep it simple) .
4137
4238``` php
4339<?php
4440
45- $coffee = file_get_contents( 'path/to/source.coffee') ;
41+ $file = 'path/to/source.coffee';
4642
4743try
4844{
49- $js = CoffeeScript\Compiler::compile($coffee);
45+ $coffee = file_get_contents($file);
46+
47+ // See available options below.
48+ $js = CoffeeScript\Compiler::compile($coffee, array('filename' => $file));
5049}
5150catch (Exception $e)
5251{
@@ -56,13 +55,27 @@ catch (Exception $e)
5655?>
5756```
5857
58+ Available options:
59+
60+ * ** filename** - The source filename, formatted into error messages
61+ * ** header** - Add a "Generated by..." header
62+ * ** rewrite** - Enable the rewriter (debugging)
63+ * ** tokens** - Reference to token stream (debugging)
64+ * ** trace** - File to write parser trace to (debugging)
65+
5966## Development
6067
6168To rebuild the parser run ` php make.php ` . Tests are run in the browser; simply
6269clone the repository somewhere Apache can see it and navigate to tests/.
6370
6471## FAQ
6572
73+ #### What was the motivation for this project?
74+
75+ I was using PHP a lot at the time and wanted to use, learn more about, and
76+ potentially contribute back to the CoffeeScript project. I thought it'd be nice
77+ to have a native version gave it a shot.
78+
6679#### Why not modify the original compiler to emit PHP?
6780
6881The compiler itself depends on Jison, which is written in JavaScript, so you'd
0 commit comments