-
Notifications
You must be signed in to change notification settings - Fork 58
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
Getting unexpected indentation errors while nesting tags and aligning tag attributes #47
Comments
A short term solution is to do your indentation like this: render: ->
<div
foo="bar"
>
<div
bar="foo"
>
</div>
</div> Note that the closing Beyond that I might be able to add a fix to correct the indentation of the output, but it's not a high priority at the moment. In the longer term I'm planning to change the output for tags to remove all newlines, but that requires other changes to be made to avoid breaking source maps. |
Thank you for taking a look. The proposed short term workaround is not pretty but it does work. Keep up the good work. Best regards, |
That's the style of indentation which React uses in their examples |
Well, I can only see a few examples for self-closing tags (which makes sense, the end of the tag itself lines up with the beginning of the tag). Unfortunately there is no example of a tag with actual children. Which kind of alignment is pretty and which is not is rather a matter of personal taste anyway. As for me it does not look that great, but it works. It is better than a compilation error as far as I am concerned :-) On the other hand I think that it should work. But I can completely understand that it might not be top priority right now though. |
@jsdf, I'm hitting this issue as well. It seems to be a bit random, because all of my components are written this way, but only some of them fail because the transformed ouput isn't valid CoffeeScript. Here's an example; try to compile it, it'll fail, but if you adjust the output to be valid CoffeeScript, it will compile. Looks like the issue is in the escaped whitespace within the object parameter. Can you just strip all of the indentation/newlines (instead of escaping it how it is now) when transforming the CJSX since it's all function calls using parentheses anyways, or act as if the CJSX closing angle bracket is on the next line so it generates correct CoffeeScript? Could you give me a quick download on how the parser works and I can create a pull request? I saw that you're no longer actively maintaining this, but I'd love to help out because I'm actively using this library. |
Sorry, still testing the above. Didn't mean to create the pull request on upstream master. Also didn't mean to spam with the issue references, I didn't know it would show up before I create the PR. 😞 (I really wish you could clean up noise like that in issues. My bad.) |
Quick and dirty fix for jsdf#47. This removes whitespace and newlines around an escape character when an escape character is present, replacing it with a single space.
Quick and dirty fix for jsdf#47. This removes whitespace and newlines around an escape character when an escape character is present, replacing it with a single space.
Hi,
I just ran into unexpected indentation errors while aligning tag attributes vertically within a cjsx file.
gives me the following error:
This is while using it through
coffee-reactify
. Using thecjsx
command line tool, however, shows an error too:Trying a by-hand-conversion of the example online with the [https://facebook.github.io/react/jsx-compiler.html](live react compiler):
does not reveal any errors so I guess it is not an error within jsx but within cjsx..
And given the fact that all the grunt work of coffee-react is done by coffee-react-transform I presume this belongs here.
Aligning tag attributes like this makes the whole thing easier to read if things get more complicated (extra callbacks, several custom props a.s.o) and it would be great if this could be fixed!
Best regards,
Rico Moorman
Version information:
The text was updated successfully, but these errors were encountered: