Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not rendering &amp symbol in html from backend data

I had created a project on express handlebars which fetches some data from youtube API but the data had some special characters like &39# ( ' symbol) &amp ( & symbol) in the title Whenever I am rendering some data using handlebars, It is rendering the title as it is

SENDING DATA FROM Backend

router.get("/demo", (req, res, next) => {
  res.render("demo", {
    data:
      "Smith  & Jone' Car ",   // simply means Smith & Jone's Car
  });
});

RENDERING DATA VIA HANDLEBARS

<div class="bg-white container2 px-3 py-1">
    <a href="#">
        {{data}}    
    </a>
</div>

like image 596
KaranManral Avatar asked Oct 25 '25 00:10

KaranManral


2 Answers

According to official docs from handlebars

use {{{data}}}

instead of

<div class="bg-white container2 px-3 py-1">
    <a href="#">
        {{data}}    
    </a>
</div>
like image 162
Rakesh Sinha Avatar answered Oct 26 '25 14:10

Rakesh Sinha


use

<div class="bg-white container2 px-3 py-1">
    <a href="#">
        {{{data}}}
    </a>
</div>

instead

like image 37
Joshua Avatar answered Oct 26 '25 15:10

Joshua



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!