-
Notifications
You must be signed in to change notification settings - Fork 2k
heredoc for CS? #81
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
Comments
That's kinda why CS supports multiline-strings (take a look at the bottom of the docs). What would you like to do differently with a here-doc? The fancy left-hand-indentation-thing that you can do with Ruby's |
The biggie is removing the need to escape quotes. |
Ahh. Mind pasting in your use-case here? I think that doing Python-style triple quotes, with left-hand indentation suppressed, would be awfully nice. Combine that with interpolation, and you almost remove the need for JavaScript templates. |
Oh yeah, add interpolation :-) #{...} syntax? Use case: |
Alright Jots -- heredocs are now on master. They're triple-quote (either single or double quotes will do) and keep track of their indentation from the left -- so you can use them from any level of code. This:
Compiles to:
Closing the ticket... |
Here's a bug bin/coffee -e "html: ''' <strong> cup of coffeescript </strong> '''" gives var html; html = "<strong> cup of coffeescript </strong>"; |
Thanks for adding this Jeremy! if you ever decide to change it to the normal heredoc syntax, you'll have my vote. I think it's more well known than triple quote (bash, perl, ruby etc.. use "<<") and it allows for triple quote to exist in the string. Still, I do appreciate the triple quote! |
Thanks for the bug report, weepy -- I've changed the way heredocs work to use smallest left-hand indentation within the heredoc as the indentation level (it used to take the indentation level of the first line). As for the |
re: |
what do you think of adding heredoc to CS? perhaps like ruby's heredoc
http://blog.jayfields.com/2006/12/ruby-multiline-strings-here-doc-or.html
I would find it useful, for instance: setting a variable to a chunk of CS source code.
The text was updated successfully, but these errors were encountered: