Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using HTML entities like – or — with template literals

Having this template literal:

`HH:MM${myValue? '' : ', XXX'}${anotherValue} - ` 

I want to replace the hyphen at the end (-) with en dash () by using its code –.

I tried several methods but none of them worked. For example:

`HH:MM${myValue? '' : ', XXX'}${anotherValue} – ` 

and

`HH:MM${myValue? '' : ', XXX'}${anotherValue}  + '–'`

Any ideas how to do this?

like image 443
Leo Messi Avatar asked Dec 18 '25 23:12

Leo Messi


1 Answers

You can't use html entities in a template literal. But you can use the unicode equivalent of the –:

`HH:MM${myValue? '' : ', XXX'}${anotherValue} \u2013 `

See here: https://www.fileformat.info/info/unicode/char/2013/index.htm

like image 145
Ringo Avatar answered Dec 20 '25 13:12

Ringo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!