-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Docs for tagged template literals #4372
Docs for tagged template literals #4372
Conversation
Should use Coffeescript form of interpolated strings, not Javascript!
So the new 'tagged template literal' code example isn't working inline on the documentation page, for:
I'm wondering if there's an issue with the CS compiler used as part of the documentation page. The code example correctly compiles and runs with |
On a similar note, the "load" button is also failing for the next backtick example (added in #4369), which looks like:
|
Did you rebuild the browser compiler? |
You should add a note that the output is ES2015, and the runtime must support tagged template literals (or another tool like Babel converts it down). Also we need to add this feature to the list of ES opt-in features mentioned in the new introduction. |
@GeoffreyBooth I've fixed all the doc issues, though feel free to tweak:
|
… the runtime is; fix CoffeeScript spelling
… into the same sentence
@greghuc I made some fixes to be more consistent in style with the rest of the docs, then I went and made some editorial changes 😄 Nothing too drastic: in the intro, I figured we might as well lump generator functions and tagged template literals in the same list; and in the explanation for the tagged template literals section, I thought it needed to be clearer that CoffeeScript was outputting ES2015 and leaving it to the runtime to do the interpolation, rather than CoffeeScript handling it. That still might not be clear enough. Anyway I don’t mean for these changes to be the final word, so please let me know if you think any changes I made worsened things 😄 |
Also |
I like the documentation as it is now in this PR. Still, I wonder if we should explain how tagged template literals work or leave learning JavaScript to the user. It doesn't matter much to me – I just wanted to hear your thoughts. |
I tweaked the explanation text to be less clunky: I moved the "outputting ES2015 warning" part to the end, and rejigged it. So the first part explains what a tagged template literal does, and the second part gives the ES2015 warning. I think it's clearer, but feel free to change. I now like the documentation as it stands. Regarding whether "we should explain how tagged template literals work", I think we should, but only in general terms. We've done this in two sentences, but I'd imagine any developer who wants to use tagged template literals would read the MDN page. They take some time to get your head round. Regarding examples, I think the complexity of I have the impression that tagged template literals are primarily a 'black-box' tool for developers writing templating libraries. So you can have an html/regex templating library that's called very cleanly using a tagged template literal. But no-one (but the library developer) sees inside the 'tag' function, which hides all the complexity. That's why |
What I don’t like is the sentence that says “Coffeescript will interpret this ‘function plus string’ combination as an ES2015 tagged template literal, and behave accordingly”. First off, the spelling is “CoffeeScript”, but secondly, it implies that CoffeeScript is doing the interpolation like it does for regular interpolated strings; in this case, we’re relying on the runtime to do that. |
Feel free to make any changes you want :-)
My internet connectivity will be very sporadic over the next few days, so I’m not going to be doing any more work on this.
… On 25 Nov 2016, at 16:45, Geoffrey Booth ***@***.***> wrote:
What I don’t like is the sentence that says “Coffeescript will interpret this ‘function plus string’ combination as an ES2015 tagged template literal, and behave accordingly”. First off, the spelling is “CoffeeScript”, but secondly, it implies that CoffeeScript is doing the interpolation like it does for regular interpolated strings; in this case, we’re relying on the runtime to do that.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#4372 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFGSTrWoHGCX6QoxPXoeAIHQMPTQSw-hks5rBxCcgaJpZM4K7F4R>.
|
… doing, and emphasize runtimes vs Babel/Traceur
Okay, I rewrote a bit more, hewing closer to @greghuc’s original text but hopefully making the distinction clearer between what CoffeeScript is doing versus what the runtime is doing. @lydell, what do you think? If this looks good to you I think we’re done. Once this is merged in, I think we can release 1.12. I have a PR open against highlight.js to enable its support for triple backticks, and they recently accepted another PR of mine for new CoffeeScript keywords; but neither PR is in the released highlight.js yet. I was thinking that I could update my local Anyway 1.12 would feature tagged template literals, triple backticks/escaped backticks, and |
All looks good to me! The plan for 1.12.0 looks good as well. I'd go with the alternative of using the best highlight.js version available locally, and leave package.json as is for now. While doing the release PR, would you mind checking if https://github.com/jashkenas/coffeescript/wiki/%5BHowto%5D-Hacking-on-the-CoffeeScript-Compiler#11-preparing-a-new-release needs updating along the way? (I'm thinking if the new docs setup is different or something.) |
@lydell will do. I guess we should also add |
Yes. |
Docs for #4352. Demonstrates use of tagged template literals.