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 fails on inline string containing HTML

See original GitHub issue

As demonstrated in this fiddle, the following is interpreted literally:

<p>{{{ '<strong>hello</strong> world' }}}</p>

Instead, I would expect it to produce:

<p><strong>hello</strong> world</p>

This also occurs with normal interpolation ({{ }}).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Biliecommented, Sep 10, 2016

Hi

I am not entirely convinced this should be considered a bug. According to the docs: The mustache tag will be replaced with the value of the msg property on the corresponding data object. In your example there is no data object.

To be able to get an error message I modified your example from

<p>{{{ '<strong>hello</strong> world' }}}</p>

to

<p v-html="<strong>hello</strong> world"></p>

as the docs state the triple curly braces will ultimately be compiled as v-html directive. Then you can see in the console the following warning:

[Vue warn]: Invalid expression. Generated function body: <scope.strong>scope.hello</scope.strong>scope.world

What is happening here is vue is looking for the properties on the data object but cannot find them because they are not there. Here is a working example: https://jsfiddle.net/bsyxkxy2/

0reactions
yyx990803commented, Apr 17, 2018

Closing 1.x issues as 1.x is now end of life and will only receive critical security patches.

Read more comments on GitHub >

github_iconTop Results From Across the Web

interpolate variables in strings in JavaScript not working when ...
I want to interpolate the words_to_be_removed variable with the defaultMessageTest string. I have tried the below 3 methods but none of them ...
Read more >
string interpolation - format string output - Microsoft Learn
When an interpolated string is resolved to a result string, items with interpolation expressions are replaced by the string representations ...
Read more >
String Interpolation in JavaScript - Dmitri Pavlutin
In JavaScript, the template string implements the string interpolation. A template string is defined by wrapping a sequence of characters into ...
Read more >
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
Displaying values with interpolation - Angular
Interpolation refers to embedding expressions into marked up text. By default, interpolation uses the double curly braces {{ and }} as delimiters.
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