Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoffeeScript in Rails #1

Closed
ox opened this issue Dec 25, 2009 · 4 comments
Closed

CoffeeScript in Rails #1

ox opened this issue Dec 25, 2009 · 4 comments
Labels

Comments

@ox
Copy link

ox commented Dec 25, 2009

Would it be possible to call CoffeeScript compiling calls within a rails app itself and for the written CS code to be converted to JS on the server call? So instead of compiling a separate script, why not just write it natively in the rhtml <%= %> tags, or in the controller or in the helper? seems like a better use of CoffeeScript, especially for teaching or using Prototype or script.aculo.us

@jashkenas
Copy link
Owner

Sure, you could totally integrate it with a Rails app in that way:

require 'coffee-script'
CoffeeScript.compile(string)

Go right ahead and make that a helper function or special partial.

@ox
Copy link
Author

ox commented Dec 26, 2009

def cs(string)
"#{CoffeeScript.compile(string)}"
end

there ya go. :P

@jashkenas
Copy link
Owner

Now, jnicklaus' BistroCar solves this problem neatly:

http://github.com/jnicklas/bistro_car/

@d2kagw
Copy link

d2kagw commented May 1, 2010

I've been having issues with this method, I can't seem to create classes using the class syntax for scripts compiled using either gem.

I get this error:

CoffeeScript::ParseError: line 2: syntax error, for '2' unexpected indent

The code is:

class Animal
  color: null
  getColor: ->
    @color

Any ideas why this would be happening?

EDIT: I should point out that the script compiles without error using coffee on the command line.

sjorek pushed a commit to sjorek/coffee-script that referenced this issue Sep 17, 2013
Enhancement: Add more block-comment related tests
protez pushed a commit to protez/coffee-script that referenced this issue Jul 28, 2015
alangpierce added a commit to alangpierce/coffeescript that referenced this issue Aug 6, 2016
Also update package.json with the package name.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants