question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Includes now throwing errors

See original GitHub issue

After updating to the latest version of EJS, I am now getting errors while compiling my EJS templates.

The error message is: SyntaxError: Unexpected token .

I believe the lines causing these issues are include lines such as the following, as when removing such lines the errors cease. <% include ../partials/bootstrap/bootstrap_header.ejs %> <% include ../partials/main_components/head_to_body.ejs %>

I couldn’t find any changes in the changelog which would cause this. Thanks,

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ghostcommented, Nov 25, 2019

Ok, sorry for the lacking research.

For anyone else with the issue, you can change the old version of include: <% include ../partials/bootstrap/bootstrap_header.ejs %> to: <%- include('../partials/bootstrap/bootstrap_header.ejs') %>

1reaction
mdecommented, Nov 24, 2019

It’s in the current changelog: “Removed legacy preprocessor include.” That usage of include is leftover from the very old v1, and was left for one major version (and for quite a long time) for backward compatibility.

We are following the semver convention of a major version bump when changing the public API. In fact, this hacky legacy feature was never actually documented in v2, but there were tests for it, so we have done a major version bump to v3. If your app depends on this feature, you can continue to install a v2.x.

Otherwise, you can convert to the modern include function call that is well documented, well supported, and will continue to exist in all future versions of EJS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

throw - JavaScript - MDN Web Docs - Mozilla
The throw statement throws a user-defined exception. Execution of the current function will stop (the statements after throw won't be executed) ...
Read more >
How to Throw Exceptions in Java - Rollbar
Throwing an exception is as simple as using the "throw" statement. You then specify the Exception object you wish to throw. Every Exception...
Read more >
Types of exceptions that can be handled by tri-catch
Basically you catch pure JavaScript errors and ServiceNow APIs only throw real errors in rare cases. Unfortunately, you have to check the ...
Read more >
How can I write a test which expects an 'Error' to be thrown in ...
js module I have the following code: throw new Error("Parsing is not possible");. Now I try to write a ...
Read more >
Error handling, "try...catch" - The Modern JavaScript Tutorial
For all built-in errors, the error object has two main properties: ... Now catch became a single place for all error handling: both...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found