admin管理员组

文章数量:1315952

Is there a way to tell CoffeeScript to just ignore a certain line and output it as is?

I want this line to be included in the resulting javascript

#import './blah/blah'

But CoffeeScript is piling it as a ment so it ends up as

//import './blah/blah'

I need it to not do that because the script is being used for Apple's UIAutomation Instrument to drive iPhone UI. UIAutomation recognizes special #import statements but not if they are getting turned into javascript ments.

Is there a way to tell CoffeeScript to just ignore a certain line and output it as is?

I want this line to be included in the resulting javascript

#import './blah/blah'

But CoffeeScript is piling it as a ment so it ends up as

//import './blah/blah'

I need it to not do that because the script is being used for Apple's UIAutomation Instrument to drive iPhone UI. UIAutomation recognizes special #import statements but not if they are getting turned into javascript ments.

Share Improve this question edited Apr 12, 2012 at 19:36 Jacob Schoen 14.2k15 gold badges86 silver badges107 bronze badges asked Feb 20, 2012 at 8:16 Christian SchlenskerChristian Schlensker 22.5k20 gold badges78 silver badges122 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Enclose the statement with backicks (`)

`#import './blah/blah'`

You can use any JavaScript code that way.

Doh, found the answer in the coffeescript docs

hi = `function() {
  return [document.title, "Hello JavaScript"].join(": ");
}`

本文标签: Have CoffeeScript output a line as raw javascriptStack Overflow