coffeescript

Iron Router Route Allow/Deny

梦想与她 提交于 2019-12-23 02:52:30
问题 I'm writing a a meteor application right now, and am getting used to the new Iron Router package (as opposed to the router package that I used before). I have a collection of routes that should only be accessible by users with specific properties. To be specific, I'm using the Roles package. My way of achieving this at the moment is to define a before function that runs a conditional, and redirects to a login or error page if the user doesn't have the proper role. Here's just a quick

Angular equivalent of .done in jquery

余生颓废 提交于 2019-12-23 00:43:28
问题 I cannot find an alternative solution to what I am trying to do, lets say I have this code in jquery: $.get 'file.json', (re) -> for k, v in re tpl = "<div>{{v.content}}</div>"; $ '#container'.append tpl .done () -> impress().init() That works fine because, .done executes the code only after the ajax, but angular seems like don't have some like .done , and impress().init() cannot reinitialize when the content was loaded, therefore there will be a mistake on data binding.. Here is my attempt

Declaring a different compile path for CoffeeScript

假装没事ソ 提交于 2019-12-22 18:45:37
问题 I have a Scalatra app that compiles CoffeeScript, using https://github.com/softprops/coffeescripted-sbt, to a default location, target/scala-2.9.1/resource_managed/main/js . I want to put the generated javascripts somewhere available to me publicly, in a folder called src/main/webapp/coffee , but the example given defaults to `/target/...' resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_ / "your_preference" / "js") My build.sbt: seq(coffeeSettings: _*) // doesn

Difference between ES2015 `import * as` vs just plain `import`

痞子三分冷 提交于 2019-12-22 10:56:39
问题 I just fixed a bug by changing import * as CodeMirror to just plain import CodeMirror . I copied this code. (Porting it from TypeScript) import * as CodeMirror worked until an addon was imported for its side effects: the expected new fold property was undefined. Questions: (I am trying to understand what happened better) What is going on? How did this change fix the bug? Who is adding the default property to CodeMirror? (Or more likely: wrapping the module inside another object that looks

JQuery events are not working on heroku in production but work in development

倖福魔咒の 提交于 2019-12-22 10:49:02
问题 this seems to be a common problem but I haven't found a solution applicable for my case. I have some JQuery in bikes.js.coffee that works correctly in development locally. When I push to Heroku the script in bikes.js.coffee does not run. There is no error in the browser's javascript console. I am using Rails 4.0. From reading around I believe it is some error in the way the assets are compiled but I am unable to get beyond that. All images show up fine in production. bikes.js.coffee: ready =

grunt-contrib-handlebars - Output is different than when I run the handlebars npm task

雨燕双飞 提交于 2019-12-22 10:28:13
问题 Thank you in advance for your time and help. I'm trying to precompile handlebars (.hbs) templates using grunt-contrib-handlebars When I run the run task I end up with this: this["JST"] = this["JST"] || {}; this["JST"]["app/templates/err.hbs"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [4,'>= 1.0.0']; helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this

Does node.js, backbone, socketio and express and coffee script all go together?

[亡魂溺海] 提交于 2019-12-22 10:06:33
问题 I'm trying to get an overview of what's latest and greatest, and was curious how all these different technologies fit together. Is it like this: Nodejs is a webserver, backbone is just a framework that will run on nodejs? SocketIO is a library that works with backbone then? And the actual code can be written in coffescript, which when compiled, will be javascript. What about express then? Could this be used. Please point out if these are components/frameworks that don't work together etc. 回答1

Cannot use 'in' operator to search for '_id' in

北战南征 提交于 2019-12-22 09:19:30
问题 I'm trying to get an existing user document using mongoose with express but I only get this: /webroot/api.domain.com/production/node_modules/mongoose/lib/document.js:162 if (obj && '_id' in obj) continue; ^ TypeError: Cannot use 'in' operator to search for '_id' in Account at model.Document._buildDoc (/webroot/api.domain.com/production/node_modules/mongoose/lib/document.js:162:27) at model.Document (/webroot/api.domain.com/production/node_modules/mongoose/lib/document.js:67:20) at model.Model

Immediately invoked named functions

ぃ、小莉子 提交于 2019-12-22 08:17:15
问题 A friend of mine posed an interesting question to me today about how to write immediately invoked named functions in CoffeeScript without hoisting the function variable to the outer scope. In JavaScript: (function factorial(n) { return n <= 1 ? 1 : n * factorial(n-1); })(5); The best I could come up with in CoffeeScript: do -> do factorial = (n = 5) -> if n <= 1 then 1 else n * factorial(n-1) looks a bit awkward. Is there a better way to do this? 回答1: You can’t. CoffeeScript doesn’t support

Javascript code execution order strangeness

你。 提交于 2019-12-22 08:07:17
问题 I have a section of Javascript/Coffeescript that seems to be executing out of order. console.log list console.log list[card_number] if list[card_number] console.log "MATCHES" new_card = list[card_number] else console.log "NO MATCHES" new_card = create_new_card(card_number) create_new_card: (card_number) -> new_card = card_number: card_number list[new_card.card_number] = new_card return new_card Every time I run this, the first console.log shows a list of cards that includes the new_card, Even