Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't write multiline codes in Coffeescript Interactive Mode(REPL)

When I typed multiline in coffeescript interactive mode, an error occrured.

For example, I want to try the following code:

kids =
  brother:
    name: "Max"
    age:  11
  sister:
    name: "Ida"
    age:  9

This Error was displayed:

coffee> kids = 
Error: In repl, Parse error on line 1: Unexpected 'TERMINATOR'
  at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
  at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
  at /usr/lib/coffeescript/coffee-script.js:26:22
  at Object.eval (/usr/lib/coffeescript/coffee-script.js:64:17)
  at Interface.<anonymous> (/usr/lib/coffeescript/repl.js:18:26)
  at Interface.emit (events:27:15)
  at Interface._ttyWrite (readline:309:12)
  at Interface.write (readline:147:30)
  at Stream.<anonymous> (/usr/lib/coffeescript/repl.js:35:17)
  at Stream.emit (events:27:15)

I tried to use '\' as a newline,but the same error was displayed.

coffee> kids = \
Error: In repl, Parse error on line 1: Unexpected '\'
  at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
  at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
  at /usr/lib/coffeescript/coffee-script.js:26:22
  at Object.eval (/usr/lib/coffeescript/coffee-script.js:64:17)
  at Interface.<anonymous> (/usr/lib/coffeescript/repl.js:18:26)
  at Interface.emit (events:27:15)
  at Interface._ttyWrite (readline:309:12)
  at Interface.write (readline:147:30)
  at Stream.<anonymous> (/usr/lib/coffeescript/repl.js:35:17)
  at Stream.emit (events:27:15)

I can't use multiline, so I can't use indentation.

What should I do?

My environment is the following:

  • OS: Ubuntu 10.04 lucid

  • coffeescript version 1.0.0 I installed coffeescript with PPA and apt-get command.

see this url: https://launchpad.net/~gezakovacs/+archive/coffeescript

like image 281
utwang Avatar asked May 08 '12 02:05

utwang


People also ask

How do I use CoffeeScript in HTML?

You simple need to add a <script type="text/coffeescript" src="app. coffee"></script> to execute coffee script code in an HTML file. In other cases, I've seen people use the attributes of type="coffeescript" and type="coffee" , so they might work for you as well. Save this answer.

What is .coffee File?

JavaScript file written in CoffeeScript, a programming language that compiles and transcompiles to JavaScript; saved in a text format and contains code that is similar to JavaScript, but modified to be more readable. CoffeeScript's aim is to enhance JavaScript's brevity and readability.


2 Answers

You can also switch to multiline mode with Ctrl+V.

like image 78
fulmicoton Avatar answered Sep 24 '22 05:09

fulmicoton


backslash works fine with my coffee 1.2.1... try to upgrade :)

like image 41
alex Avatar answered Sep 23 '22 05:09

alex