coffeescript icon indicating copy to clipboard operation
coffeescript copied to clipboard

How to write one line comment without ';'

Open iron9light opened this issue 14 years ago • 8 comments

`// <debug>`

will compile to

// <debug>;

How can I remove the ';' ?

I want

// <debug>

iron9light avatar Jul 09 '12 16:07 iron9light

I believe you can just do this:

# <debug>

cache-rules avatar Jul 09 '12 16:07 cache-rules

There's no way to generate single-line comments in the output. That is not a feature we wish to have as part of the language.

edit: for those of you that want to go against the strong suggestion that you avoid backticks, just put a newline inside the backticks.

michaelficarra avatar Jul 09 '12 17:07 michaelficarra

You mean this?

`// <debug>
`

This will generate

//aaa
;

iron9light avatar Jul 09 '12 17:07 iron9light

... which is what you wanted.

michaelficarra avatar Jul 09 '12 17:07 michaelficarra

→ #1473

Block comments don't recieve semicolons. Likewise, JS literals shouldn't get semicolon-ed as they should be providing their own.

$ coffee -bce '### ###'
// Generated by CoffeeScript 1.3.3
/*
*/

$ coffee -bce '`/**/`'
// Generated by CoffeeScript 1.3.3
/**/;

satyr avatar Jul 10 '12 01:07 satyr

I want

// <debug>

and I think

// <debug>
;

is OK for me.

iron9light avatar Jul 10 '12 02:07 iron9light

@iron9light Just curious, is it for documentation, similar to jsdoc?

OnesimusUnbound avatar Jul 10 '12 10:07 OnesimusUnbound

No, it's for Sencha Touch (or ExtJS) They will remove all things between //<debug> and //</debug> when compact js

iron9light avatar Jul 11 '12 02:07 iron9light