Not rendering &amp symbol in html from backend data

Viewed 251

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>

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>

use

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

instead

Related