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 have the code: FilterableTable = getPostUrl: -> @options.postUrl setPostUrl: (x) -> @optsions.postUrl = x options: { postUrl: 'unknown' } $.widget "ui.FilterableTable", FilterableTable When it renders the .js it wraps it in function()... (function() { var FilterableTable; FilterableTable = { getPostUrl: function() { return this.options.postUrl; }, setPostUrl: function(x) { return this.optsions.postUrl = x; }, options: { postUrl: 'unknown' } }; $.widget("ui.FilterableTable", FilterableTable); }).call(this); but most implementations of coffeescript generates:
var FilterableTable; FilterableTable = { getPostUrl: function() { return this.options.postUrl; }, setPostUrl: function(x) { return this.optsions.postUrl = x; }, options: { postUrl: 'unknown' } }; $.widget("ui.FilterableTable", FilterableTable); Is this customizable anywhere/ |
|
|
Hmm, what you're posting as "most implementations" looks to me like the "bare" switch on the CoffeeScript compiler, and it's usually recommended not to generate bare output because of namespacing issues. We just call the CoffeeScript compiler with the default options so we are inheriting the non-bare default from CoffeeScript rather than doing anything to force it. We do plan at some point to provide a way for you to customise the compiler options, so you could pass the bare flag yourself, but this isn't available yet and we don't have an estimated timescale. We'll try to bump it up the priority list for you though! |
|
|
Yes. I'm also for that: recently I was refused from using CoffeScript just because of absense of bare switch. It could VERY useful addition. +1 for that!!! |
|
|
Ahh, I haven't been using it for long, so I wasn't aware of the 'bare switch'. Actually, the more I play with it, the more I think its not necessary for me... I was primarily messing around with it to create a jQuery widget... |
|
|
Not just jQuery widget, but with just some code, needed to run after page load. |
|
|
reading a book on coffeescript and it says it indeed does that by default. Guess I'll keep reading to see if it suggests the best way to encapsulate something like a jQuery widget.... Something reusable. |
|
|
I had "assumed" otherwise because the "Try Coffeescript" link on the official website didn't wrap it.... |
|
|
In case anyone is following this, I think I've gotten some guidance here:
|
|
|
ahh, this works great for creating widgets.... So sorry for ever doubting you guys :-)
$.widget 'ui.testPlugin', { _init: -> console.log 'init' doSomething: -> console.log 'something else' } |
|
|
I too would really like to see the --bare flag. I like to divide my code up into segments, and the lack of this flag makes that a bit difficult. |
|
|
Its actually fairly easy to do that, breaking up into files. If you use the JQuery UI widget factory, then it becomes available via the global JQuery object. Also, you can attach it to the window. Figured this out while learning backbone.js.... So far, haven't had a need to use the --bare functionality. |
|
|
I'm using requirejs, and all my modules are already protecting the global namespace. While it doesn't hurt to wrap them again, it's unnecessary. Looking forward to being able to set compiler options using Workbench. |
|
|
Hey folks, There will be interim support for "unwrapped" (bare) function compilation in the next update. Longer term we plan to offer a properties-style UI for setting up compilation options, but we don't have time to implement this right now, so we have instead done a 'specially formatted comment' kludge similar to what we did for Sass. From the next update, if you put the following as the first line of your .coffee file:
then this will be equivalent to passing the --bare flag to the CoffeeScript command line compiler. Note that this is sensitive to spacing and case, and we do not check it for validity -- copy it exactly as you see it! The update should be out within the next week -- VS2010 Extension Manager should notify you when it's available. |
|
|
Great, thanks so much! |
|