CoffeeScriptRedux
CoffeeScriptRedux copied to clipboard
Indented function arguments should be valid syntax
This coffeescript should be valid.
a b,
c
d
In regular coffeescript, it generates
a(b, c, d);
But redux says:
Syntax error on line 2, column 4: unexpected '\n'
1 : a b,
2 : c
^ :~~~~^
3 : d
4 :
This is preventing me from moving any of my projects to Redux as I rely on a HAML-ish DSL that works perfectly fine in regular coffeescript...
Sample:
MyView = View.extend
render: (_)->
_ '.aDiv',
_ '.aNestedDiv', 'some text'
+100 for anything like this that makes line-continuations easier to use, simpler, and sane. The CS line-continuation rules are a mish-mash at the moment and not very friendly and not documented. I've given up and mostly use backslashes at the end of lines (so ugly!).
On Sat, Mar 9, 2013 at 11:15 PM, Peter Wong [email protected]:
This is preventing me from moving any of my projects to Redux as I rely on a HAML-ish DSL that works perfectly fine in regular coffeescript...
Sample:
MyView = View.extend render: (_)-> _ '.aDiv', _ '.aNestedDiv', 'some text'
— Reply to this email directly or view it on GitHubhttps://github.com/michaelficarra/CoffeeScriptRedux/issues/83#issuecomment-14677572 .
Mine too when I try running my code:
{html, css} = require "lilyturf"
page = html ->
@div class: "new",
@span id: "none", "x"
style = css ->
"html":
"css": "red"
head:
fontSize: 10
color: @hsl 10, 20, 30
I want this pretty sorely too; there just isn't a way that's tidy to break up arguments across multiple lines in cs-redux. The only ones I have found that are legal are somewhat hideous:
someFunc 'some really long string, object, invocation or similar',
'some other pretty long, hard-to-break-into-lines anything'
someFunc(
'some really long string, object, invocation or similar'
'some other pretty long, hard-to-break-into-lines anything'
)
+1
Think about a use-case with async:
data = [0,1,2,3]
async.eachSeries data,
(elm, cb) ->
# do someting...
cb()
(err) ->
console.log "Done"
I have this type of code all over my projects. With the current implementation, I would have to write this code like this:
data = [0,1,2,3]
iterator = (elm, cb) ->
# do someting...
cb()
async.eachSeries data, iterator, (err) ->
console.log "Done"
which becomes quite hard to maintain once iterator gets longer etc.
+1
Just tried to migrate a project from the original compiler to redux. I think I'm encountering this issue for code like this:
angular.module("foobar", ["dep1",
"dep2"])
I get:
Syntax error on line 2, column 4: unexpected '(INDENT)' (\uEFEF)
1 : angular.module("foobar", ["dep1",
2 : "dep2"])
^ :~~~~^
3 :
4 :
As @johan wrote, the only way around it is to skip the indentation altogether on the continuation line, but that lowers readability drastically...
Correction: My case can be fixed with a backslash to explicitly indicate a continuation line, except on Windows where the CR isn't properly handled by the preprocessor. I'll open a separate issue.