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.

Interpolation of an unset value prints "undefined"

See original GitHub issue

Hello. While trying to implement value prefilling for my inputs I encountered many “undefined” values for unset variables.

Steps to reproduce:

  1. Go to interactive examples https://eta.js.org/docs/examples/interactive
  2. Change Eta.render('Hi <%= it.name %>', {name: 'Person'}) to Eta.render('Hi <%= it.name %>', {})
  3. Press Run button. Result is “Hi undefined”.

It is very inconvenient to use something like <%= it.name || “” %> for each interpolation especially for input prefilling. So I think showing “” instead of “undefined” is more correct. EJS thinks the same way and renders "Hi " if I modify this example for it. However if it is intended and there is another way to interpolate undefined values as “” please add it to the documentation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
AntonNechcommented, Sep 22, 2020

Thank you! Everything works great, no more “undefined”.

1reaction
willemmuldercommented, Sep 21, 2020

Yes, even better! Good thinking 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

php - Why string interpolation throws Undefined property
When I use string interpolation in Dog class to acess a method in Animal class, ... public function setName($value) { $this->name=$value; ...
Read more >
Why isn't string interpolation working? (Check for backticks)
It just prints the literal characters ${myName} without reading them as a variable. It seems to be bugged. If I type it, the...
Read more >
Interpolation technique used in numpy - Math Stack Exchange
In fact, you even have a repeated value with different corresponding fp values! In this case, the behavior is undefined.
Read more >
Template Designer Documentation - Jinja
for Expressions to print to the template output ... If a variable or attribute does not exist, you will get back an undefined...
Read more >
10.2. Parameter Substitution
Once again: variable= # variable has been declared, but is set to null. echo "${variable-0}" # (no output) echo "${variable:-1}" # 1 #...
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