0

I want to create a comment in coffeescript that transpiles to the following js:

//# This is a comment with an hash

The # in the comment is necessary because of a framework build script (qooxdoo) that uses the hashed comment as a directive. And of course that is a bit tricky as the # is used to demarcate a comment.

How can a put a hash (#) in a coffeescript comment such that the # is transpiled to javascript in a comment?

halcwb
  • 1,480
  • 1
  • 13
  • 26
  • @mu is too short. I don't think that this question already has been answered. Please read both my question and answer and compare this with the so-called duplicate: http://stackoverflow.com/questions/7781685/coffeescript-how-to-comment-this-doesnt-work. – halcwb Dec 26 '14 at 21:31
  • But the answers cover the same material: "how do CoffeeScript comments work?" – mu is too short Dec 26 '14 at 21:34
  • But maybe I was a little quick with the Golden Hammer of Closing. – mu is too short Dec 26 '14 at 21:44
  • @muistooshort. It's a bit of a detail, I know, but just in case anyone else wants to use a hash in a coffeescript comment. – halcwb Dec 26 '14 at 23:12

1 Answers1

1

Found it:

###*
# #This is a comment with a hash
###

At least within a block comment this transpiles to:

/**
 * #This is a comment with a hash
 */
halcwb
  • 1,480
  • 1
  • 13
  • 26
  • Only `###` comments actually get through to the JavaScript so AFAIK the problem isn't that you have `#` inside a CoffeeScript comment, the problem is that CoffeeScript removes (most) comments along the way. You could use backticks to embed a raw JavaScript comment too but that would be nasty. – mu is too short Dec 26 '14 at 23:46