最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Have CoffeeScript output a line as raw javascript? - Stack Overflow

programmeradmin1浏览0评论

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(": ");
}`
发布评论

评论列表(0)

  1. 暂无评论