I am getting data from a database, and in that data I have found some of the HTML tags in the form of a string, but when I display data to the frontend side I saw HTML tags are also. I want to convert that HTML tags data into there real value using ejs.
my code is -
fetch data -
app.get("/blogs/:id", (req, res) => {
const requestParams = _.lowerCase(req.params.id);
blogData.forEach(function (post) {
const storedTitel = _.lowerCase(post.heading);
if (storedTitel === requestParams) {
res.render("blogsfullDetails", {
date: post.date,
heading: post.heading,
subheading: post.subheading,
discription: post.discription,
discription2: post.discription2,
image: post.image,
image2: post.image2,
});
}
});
});
ejs file -
<div class="blogTitle">
<p class="date text-center"><%= date %></p>
<p class="blog-heading text-center"><%= heading %></p>
<p class="subText text-center"><%= subheading %></p>
<div class="socialMedia">
<a href="" target="_blank" ><i class="fa fa-linkedin fa-2x" style="color: #0e76a8 ;" aria-hidden="true"></i></a>
<a href="" target="_blank" ><i class="fa fa-instagram fa-2x" style="color: #fb3958;"></i></a>
<a href="" target="_blank" ><i class="fa fa-facebook-square fa-2x" style="color: #4267B2;"></i></a>
</div>
</div>
<div class="blog-main-image" style="background-image: url('<%= image2 %>')"></div>
<div class="blogText">
<p><%= discription %></p>
<div class="blog-main-image" style="background-image: url('<%= image %>')"></div>
<p><%= discription2 %></p>
</div>
frontend image -
I know how to convert Html data in text using dangerouslySetInnerHTML in React but don't know how to do it in ejs please help