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

Make REPL support multiline template literals #333

Closed
wants to merge 1 commit into from
Closed

Make REPL support multiline template literals #333

wants to merge 1 commit into from

Conversation

ziyunfei
Copy link
Contributor

> content="io.js"
'io.js'
> console.log(
... `<html>
...   <body>
...     <div>
...     ${content}
...     </div>
...   </body>
... </html>
... `)
<html>
  <body>
    <div>
    io.js
    </div>
  </body>
</html>

@bnoordhuis
Copy link
Member

Your PR looks reasonable to me but can you:

  1. Add regression tests to test/parallel/test-repl.js?
  2. Update the commit log (see CONTRIBUTING.md and git log lib/repl.js for examples.)
  3. Sign the commit with your real name (git config --global user.name, ditto for user.email)

Thanks!

@bnoordhuis
Copy link
Member

@ziyunfei Ping.

/^(Unexpected end of input|Unexpected token :)/.test(e.message);
function isRecoverableError(e, self) {
if (e && e.name === 'SyntaxError') {
if (e.message == 'Unterminated template literal') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are actually a few different messages you could get, unterminated_template and unterminated_template_expr in particular would affect this (https://github.com/v8/v8-git-mirror/blob/master/src/messages.js#L25-L26)

Let REPL enter multiline mode if user's input contains
unterminated template literals.
@ziyunfei
Copy link
Contributor Author

@bnoordhuis Pong, sorry for the long delay.

@ziyunfei ziyunfei changed the title Make REPL support multiline template string Make REPL support multiline template literals Jan 19, 2015
bnoordhuis pushed a commit that referenced this pull request Jan 19, 2015
Let REPL enter multiline mode if user's input contains unterminated
template literals.

PR-URL: #333
Reviewed-By: Ben Noordhuis <[email protected]>
@bnoordhuis
Copy link
Member

Thanks @ziyunfei, landed in b7365c1. Nice addition!

@bnoordhuis bnoordhuis closed this Jan 19, 2015
@caitp
Copy link
Contributor

caitp commented Jan 19, 2015

beware of the segfault bug in template strings atm :( just fixed this morning

@bnoordhuis
Copy link
Member

@caitp Is that https://codereview.chromium.org/857433004? I saw that, hadn't realized it fixes a segfault. Is it going to get back-ported to 4.1?

@caitp
Copy link
Contributor

caitp commented Jan 19, 2015

I hope so, it would not be a very good user experience to crash chrome on people!

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

Successfully merging this pull request may close these issues.

3 participants