coffeescript

Node.js for Windows and Macs — forward slash, backslash rectification

孤街醉人 提交于 2020-01-13 11:43:36
问题 Is there a method to rectify the discrepancy in node.js from Windows to Linux and Mac concerning the backslash versus forward slash? Windows requires backslashes when calling locations in git bash , while Mac/Linux requires forward slashes. I'm working on a project with both Mac and Windows users so I can't change all the forward slashes to backslashes in the code because when Mac users pull, coffee wont be able to properly run for them and vice versa. Is there a solution to this? 回答1: Make

Node.js for Windows and Macs — forward slash, backslash rectification

蹲街弑〆低调 提交于 2020-01-13 11:43:31
问题 Is there a method to rectify the discrepancy in node.js from Windows to Linux and Mac concerning the backslash versus forward slash? Windows requires backslashes when calling locations in git bash , while Mac/Linux requires forward slashes. I'm working on a project with both Mac and Windows users so I can't change all the forward slashes to backslashes in the code because when Mac users pull, coffee wont be able to properly run for them and vice versa. Is there a solution to this? 回答1: Make

Unhandled rejection error Bluebird

南笙酒味 提交于 2020-01-13 10:29:21
问题 I have the following code. And it works as expected without throwing a unhandled rejection error. p = new Promise (fulfill, reject) -> reject new Error 'some error' p.catch (error) -> console.log error Now, the second code example does throw an unhandled rejection error. Can someone explain to me why this is happening when im clearly handling the error. p = new Promise (fulfill, reject) -> reject new Error 'some error' p.then -> console.log 'ok' p.catch (error) -> console.log error Btw. I'm

Warning: input is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`. Check the render method of null

柔情痞子 提交于 2020-01-13 09:30:08
问题 I am trying to render the errors in the form if the ajax call to the form URL fails. Below is my Admin component: #app/assets/javascripts/components/admin.js.coffee @Admin = React.createClass # propTypes: -> # emailVal: React.PropTypes.string.isRequired getInitialState: -> edit: false errorTexts: [] handleToggle: (e) -> e.preventDefault() @setState edit: !@state.edit @setState errorTexts: [] handleDelete: (e) -> e.preventDefault() # yeah... jQuery doesn't have a $.delete shortcut method $

Can't require local CoffeeScript modules

我们两清 提交于 2020-01-13 04:48:51
问题 I'm running Node.js 0.10.21. I tried both CoffeeScript 1.6.3 and master both with and without require('coffee-script/extensions') . Compiling the two files to JavaScript and running them directly in Node works just fine of course. # ./folder/a.coffee require('../b').test() # ./b.coffee exports.test = -> console.log 'yay' # $ coffee folder/a.coffee # # Error: Cannot find module '../b' # at Function.Module._resolveFilename (module.js:338:15) # at Function.Module._load (module.js:280:25) # at

Is is possible to load .coffee script file to browser and execute?

落爺英雄遲暮 提交于 2020-01-11 13:33:09
问题 I am trying to load coffee script inside a sample.coffee file along with the coffee-script.js file and perform some simple operations on the HTML. But i am not able to load the sample.coffee file. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="sample.coffee" type="text/coffeescript"></script> <script src="coffee-script.js" type="text/javascript"></script> </head> <body> </body> </html> Here is the coffeescript code inside sample.coffee message

Why does CoffeeScript wrap class definitions in a closure?

别说谁变了你拦得住时间么 提交于 2020-01-11 08:20:22
问题 In CoffeeScript, this: class Foo method: (x) -> x+1 Compiles to: // Generated By CoffeeScript Foo = (function() { function Foo() {} Foo.prototype.method = function(x) { return x+1; } return Foo; })() Which seems a bit excessive. The following should be functionally identical : // Generated by Dave function Foo() {} Foo.prototype.method = function(x) { return x+1; } What is the motivation for the extra "closure" wrapper? This is not merely an idle question of styling; it has implication to

Coffeescript wrapping files in a function

情到浓时终转凉″ 提交于 2020-01-10 10:39:09
问题 The coffeescript compiler is, for some reason, wrapping all of my .coffee files in a function when they are compiled. For example, if I have test.coffee: class TestClass constructor: (@value) -> printValue: () -> alert(@value) printAValue = () -> test = new TestClass() test.printValue() then I get test.js: (function() { var TestClass, printAValue; TestClass = (function() { function TestClass(value) { this.value = value; } TestClass.prototype.printValue = function() { return alert(this.value);

how to debug coffeescript in node.js with webstorm 6 source maps

喜你入骨 提交于 2020-01-10 10:16:04
问题 I've set up the coffeescript file watcher like in this video http://www.youtube.com/watch?v=Sl1Uk3zT5Fg Which seems to work fine for an html project debugging with google chrome. However, when I start debugging and set a breakpoint in the coffeescript file in a node.js project, it doesn't hit the breakpoint. Setting a breakpoint in the generated js file does however get hit. What do I need to do for the debugger to use the generated source maps and step through the coffeescript with node.js

when click on close button and when click on suggestions text with select2

喜夏-厌秋 提交于 2020-01-07 08:41:33
问题 I want check if a user click on select2 close button or only it's triggered a change event. This is my select2 input: <%= hidden_field_tag :query, params[:query], :id => "query_txt" %> On my coffeescript file: $('#query_txt').select2( #select2 options here, ajax, initSelection...etc # # # $("#query_txt").on "change", (e) -> if ($(".select2-search-choice-close").click ->) console.log "click on close" ) The problem is that if I click on suggestions text I can see the text "click on close" on my