Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indented function arguments should be valid syntax #83

Open
nickretallack opened this issue Oct 25, 2012 · 7 comments
Open

Indented function arguments should be valid syntax #83

nickretallack opened this issue Oct 25, 2012 · 7 comments
Labels

Comments

@nickretallack
Copy link

nickretallack commented Oct 25, 2012

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 :

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/85521-indented-function-arguments-should-be-valid-syntax?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).
@peterwmwong
Copy link

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'

@mark-hahn
Copy link

+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//issues/83#issuecomment-14677572
.

@tiye
Copy link

tiye commented Apr 21, 2013

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

@johan
Copy link

johan commented Aug 2, 2013

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'
)

@sebastianhoitz
Copy link

+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.

@provegard
Copy link

+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...

@provegard
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants