coffeescript

Can Haxe be compiled to Coffeescript?

谁说我不能喝 提交于 2019-12-12 04:43:21
问题 I'm wondering whether it's possible to compile Haxe to Coffeescript - are there any tools that are available for this? I find Coffeescript's syntax to be much more concise than that of Javascript, so I'd like to find a Coffeescript target for Haxe (if it exists.) 回答1: Haxe already has a Javascript target, and there is already a Javascript-to-Coffeescript that is available ( http://js2coffee.org/ ), so it should be possible, as long as js2coffee does not make any errors in compiling Javascript

return named function in coffeescript

痞子三分冷 提交于 2019-12-12 04:39:16
问题 I have the following javascript: Function.prototype.debounce = function (threshold, execAsap) { var func = this, timeout; return function debounced () { //body } }; How can I return a named function like this in coffeescript? 回答1: You can't name functions in Coffeescript. The reason is given in the FAQ -- grep for "Is there any way to name functions, for reflection and recursion?" If you really need to embed a name, you could use backticks to embed raw Javascript. 来源: https://stackoverflow

Load coffee script module in Angular

青春壹個敷衍的年華 提交于 2019-12-12 04:38:25
问题 I'm having a Angular-CLI application and I try to bring in a third party dependency in, which is written in Coffee Script . This is what I do in my component: const CoffeeWidget = require('coffee-loader!CoffeeWidget'); I thought using a coffee loader would work. But not really. Now I'm able to read the index.coffee , but in my index.coffee I require other coffee files. Like: Cup = require '../tools/cup.coffee' But it has problems to ready the cup.coffee and says: You may need an appropriate

Can't get Backbone-relational to work with AMD (RequireJS)

我怕爱的太早我们不能终老 提交于 2019-12-12 04:23:36
问题 I have the following Backbone router definition in CoffeeScript: // appointments_router.js.coffee define ["app", "appointment"], (App) -> class Snip.Routers.AppointmentsRouter extends Backbone.Router initialize: (options) -> @appointments = new Snip.Collections.AppointmentsCollection() @appointments.reset options.appointments Here is the "appointment" module on which it depends: // appointment.js.coffee define ["app", "relational"], (App) -> class Snip.Models.Appointment extends Backbone

Getting array of option closing tags after partial containing options [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-12 03:55:20
问题 This question already has answers here : What is the difference between <%, <%=, <%# and -%> in ERB in Rails? (7 answers) Closed 4 months ago . I have dynamic select boxes in my view ../diys/_form.htmlerb ... <%= f.fields_for :attached_vehicles do |av| %> <p>Select make</p> <%= av.select :make, options_for_select(@makes.collect { |make|[make.make_name, make.id] }, 0), {}, { id: 'makes_select' } %><br> <p>Select model</p> <%= av.select :model, (render "make_models/make_model"), {}, { id:

Coffeescript instance method encapsulation in an Object

心已入冬 提交于 2019-12-12 03:19:59
问题 Say I have a Coffeescript class: class Foo MyMethodsBar: () => "bar" MyMethodsBaz: () => "baz" Is there any way to encapsulate methods like this (not working): class Foo MyMethods: bar: () => "bar" baz: () => "baz" So I can call: f = new Foo() f.MyMethods.bar() The problem is that this (or @ ) is not the instance when I do this like a regular method. I'm trying to do this for cleaner mixins/concerns. Thanks, Erik 回答1: Nope, this is not possible, unless you create MyMethods inside the

Gulp: Different Pipe collections within same task (CoffeeScript and JavaScript)

旧巷老猫 提交于 2019-12-12 02:56:09
问题 What I've been attempting to do is create one scripts task that takes all .coffee and .js files and does what's needed for each: Coffee files should be run through coffee(), coffeelint() and coffeelint.reporter() JS files should be run through jshint() All files should then be run through concat(), uglify() and ultimately setting a destination as a final build file. The reason I have some .coffee and some .js is because I'm using Bower components that have JS files, even though I'd like to

Select2 - Deny to can clean the input field and disable the form if results not found

天涯浪子 提交于 2019-12-12 02:46:10
问题 I have this json file on /api/searches : [{"id":"513dbb61a61654a845000005","text":"ingeniero agrónomo"},{"id":"513a11d4a6165411b2000008","text":"ingeniero industrial"}] I'm using select2 to show results. This is my current select2 setting: $('#query_txt').select2 createSearchChoice: (term, data) -> if $(data).filter(-> @text.localeCompare(term) is 0 ).length is 0 id: term text: term width: 'resolve' minimumInputLength: 3 tags: true showSearchBox: true maximumSelectionSize: 1 closeOnSelect:

Node.js: Module does not recognize Schema

若如初见. 提交于 2019-12-12 02:44:55
问题 On server.coffee I have: User = mongoose.model 'User', s.UserSchema addEntryToCustomer = require './lib/addEntryToCustomer' and on addEntryToCustomer.coffee I have: module.exports = (phone,res,req) -> User.find {account_id: phone.account_id }, (err, user) -> And I get this error: 2011-11-14T19:51:44+00:00 app[web.1]: ReferenceError: User is not defined 回答1: In node.js, modules run in their own context. That means the User variable doesn't exist in addEntryToCustomer.coffee . You can either

How to perform server validations based on query results with Firebase?

谁都会走 提交于 2019-12-12 02:38:34
问题 When inserting a record I need to be able to run one or more queries on the server which will reject the insert if it finds any results. Will Firebase allow me to do this? It can't be specified on the client or it could be easily subverted. For a more concrete example, I have a Meteor app that currently let's me do rate limiting on votes with some pretty simple code. I would like to implement this in Firebase. (Please forgive the CoffeeScript) @VoteFrequency = votesPer: (sinceDelta, sinceUnit