Inline coffeescript import #430

Closed
Qard opened this Issue Dec 10, 2011 · 8 comments

Comments

Projects
None yet
4 participants
@Qard

Qard commented Dec 10, 2011

Just thinking, it'd be neat if we could do inline importing of external coffeescript files. For example;

:coffeescript(src='/javascripts/application.js')

If the src is specified on a :coffeescript block, it could load the file at the specified path, compile it and paste it inline.

@jprichardson

This comment has been minimized.

Show comment
Hide comment
@jprichardson

jprichardson Jan 28, 2012

Agreed. I thought it'd be possible use coffeescript like we can inline javascript like:

script(type='text/coffeescript')
  alert window.location.orgin

But unfortunately that doesn't work =(

Agreed. I thought it'd be possible use coffeescript like we can inline javascript like:

script(type='text/coffeescript')
  alert window.location.orgin

But unfortunately that doesn't work =(

@Qard

This comment has been minimized.

Show comment
Hide comment
@Qard

Qard Jan 28, 2012

Umm...you can just use the :coffeescript filter if you are talking about just having a block right in the view. What I was talking about is actually loading external .coffee files. Looking back, it's not useful enough for all the work it'd take to implement. Better to just bundle scripts anyway.

Qard commented Jan 28, 2012

Umm...you can just use the :coffeescript filter if you are talking about just having a block right in the view. What I was talking about is actually loading external .coffee files. Looking back, it's not useful enough for all the work it'd take to implement. Better to just bundle scripts anyway.

@Qard Qard closed this Jan 28, 2012

@jprichardson

This comment has been minimized.

Show comment
Hide comment
@jprichardson

jprichardson Jan 28, 2012

Oh... haha! I didn't know that. Excellent.

Oh... haha! I didn't know that. Excellent.

@tj

This comment has been minimized.

Show comment
Hide comment
@tj

tj Jan 28, 2012

Contributor

yeah haha i wouldn't implement it anyway :p getting really sick of CS stuff

Contributor

tj commented Jan 28, 2012

yeah haha i wouldn't implement it anyway :p getting really sick of CS stuff

@paulmillr

This comment has been minimized.

Show comment
Hide comment
@paulmillr

paulmillr Jan 28, 2012

Contributor

@visionmedia i'm curious -- why do you hate it? It is a better js, no? ES6 would anyway have many features from coffee e.g. short functions, list comprehensions etc.

If so, do you hate ruby / python too?

Contributor

paulmillr commented Jan 28, 2012

@visionmedia i'm curious -- why do you hate it? It is a better js, no? ES6 would anyway have many features from coffee e.g. short functions, list comprehensions etc.

If so, do you hate ruby / python too?

@tj

This comment has been minimized.

Show comment
Hide comment
@tj

tj Jan 28, 2012

Contributor

dont get me started :p I do dislike ruby but for reasons that don't have to do with syntax

Contributor

tj commented Jan 28, 2012

dont get me started :p I do dislike ruby but for reasons that don't have to do with syntax

@Qard

This comment has been minimized.

Show comment
Hide comment
@Qard

Qard Jan 28, 2012

As a regular user of coffeescript, I sympathise with TJ. It encourages long expressions far to much and that it discourages parentheses is the source of numerous issues. A great example is setTimeout. This won't work;

setTimeout -> doStuff (), 1000

There's also the ever-present potential for variables to get shadowed, which can be really hard to track down.

It's a neat experiment, but I wouldn't recommend using it for non-trivial code unless you really understand what it's doing to your code and where it's most likely to fail.

Qard commented Jan 28, 2012

As a regular user of coffeescript, I sympathise with TJ. It encourages long expressions far to much and that it discourages parentheses is the source of numerous issues. A great example is setTimeout. This won't work;

setTimeout -> doStuff (), 1000

There's also the ever-present potential for variables to get shadowed, which can be really hard to track down.

It's a neat experiment, but I wouldn't recommend using it for non-trivial code unless you really understand what it's doing to your code and where it's most likely to fail.

@paulmillr

This comment has been minimized.

Show comment
Hide comment
@paulmillr

paulmillr Jan 28, 2012

Contributor

I am not a big fan of javascript or coffeescript, they're both pretty shitty, though coffee is slightly less shitty than js. Sadly there's no other choice for frontend.

This won't work

The similar code wouldn't work, for example, in haskell. If you want to write code without parentheses (which is something coffeescript allows you to do), then format your code properly: setTimeout (-> doStuff()), 1000.

There's also the ever-present potential for variables to get shadowed, which can be really hard to track down.

This is something everyone's blaming coffee-script for but actually i've never had any issues with variables shadowing (considering i've written a lot of coffee code).

It encourages long expressions far to much

Just be consistent & follow a simple coffeescript code conventions and you won't see any readability issues.

Contributor

paulmillr commented Jan 28, 2012

I am not a big fan of javascript or coffeescript, they're both pretty shitty, though coffee is slightly less shitty than js. Sadly there's no other choice for frontend.

This won't work

The similar code wouldn't work, for example, in haskell. If you want to write code without parentheses (which is something coffeescript allows you to do), then format your code properly: setTimeout (-> doStuff()), 1000.

There's also the ever-present potential for variables to get shadowed, which can be really hard to track down.

This is something everyone's blaming coffee-script for but actually i've never had any issues with variables shadowing (considering i've written a lot of coffee code).

It encourages long expressions far to much

Just be consistent & follow a simple coffeescript code conventions and you won't see any readability issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment