This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm having an issue where the tabs in Studio appear to be conflicting with the tabs needed with coffeescript. What is the correct setup for tabs in Studio to make this work properly. (ie. i can paste into js2coffee website and can see the INDENT errors). As far as I know, I'm using the VS defaults Thanks |
|
|
We use an indent level of 2, spaces not tabs. From a quick test, this also seems to work on the js2coffee site. |
|
|
Actually, if I hit 'tab' in a coffescript file I get a totally different outcome than if I use '2 spaces' Default for my editor is 4 - which is default. So are you saying, your application overrides that - because that is not what I see. ie. hitting 'tab' produces
2 spaces creates:
source for first case of tabs:
What are you suggesting I do ? (edit post to wrap with code snippet) |
|
|
We don't override your settings; you asked "What is the correct setup for tabs in Studio to make this work properly?" and I thought you were asking for a setup that I knew worked. 4 spaces also works fine, and so does keeping tabs instead of replacing them with spaces. Both appear to paste into coffee2js correctly as well. I think this issue is that you have the
(where Change this to:
(again, or the equivalent in spaces) and you should see the correct output. |
|
|
More info: It looks like js2coffee mishandles tabs. If I use the second snippet above, it compiles correctly in Web Workbench, but on js2coffee it gives the incorrect output you describe (even though it appears to display with proper indenting). |
|
|
Side question, but is it to correct to be wrapping the code:
ie
Because in javascript when I consume this as Test.Hello(); it fails, when I remove the outer closure it works ? When I goto Try Coffeescript I get a different result that works as well:
produces:
which works ? What do you see produced? |
|
|
What you're seeing on those sites is the result of running the CoffeeScript compiler with the "bare" option. You can compile files to 'bare' JavaScript in Web Workbench by going into Mindscape > Web Workbench Settings and checking the 'Emit bare JavaScript' checkbox for that file. I believe the reasoning behind defaulting to wrapped JavaScript is to avoid polluting the global namespace (the bare version emits the name 'Test' into the global namespace). There's some discussion of this at http://jashkenas.github.com/coffee-script/#lexicalscope and under the |
|
|
Ah - ok great - that explains it Thanks for your help tonight Ivan- much appreciated! (is there a way to make that a global setting for all the files as a default?) |
|
|
Not yet. But project-level defaults for all the compilation options are definitely on the radar -- we'll announce it on the blog when they're available but we don't have a timeframe at the moment. |
|
|
For anyone else that stumbles across this, I found a good answer: http://stackoverflow.com/questions/7730242/using-javascript-generated-from-mindscape-web-workbench-coffeescript-source-in Adding the @ on the class name was what I needed to figure out :
from js:
@ on the class exposes the Test |
|