title: How to display an html string stored in the mongodb using express
body: <p>I've been stuck for displaying or rendering an html string coming from the db..So any help is appreciated.</p>
  <p>This is the rendering controller for rendering the data.</p>
  <pre><code>exports.previewPageView = (req, res, next) =&gt; {
      // We Will See This Part
      pageDataModel.findOne({url : url}).populate(&quot;page_id&quot;).exec(function(err, result){
          if(err) throw err;
          else {
              if(result == null)
              {
                  res.status = 404;
                  next();
              }
              else
              {
                  var obj = {};
                  for(let i = 0; i &lt; result.pageData.length; i++)
                  {
                      if(result.pageData[i].imagePath == undefined)
                      {
                          let name = result.pageData[i].fieldRef;
                          obj[name] = ejs.render(result.pageData[i].fieldValue, {category : req.params.category});
                      }
                      else
                      {
                          let name = result.pageData[i].fieldRef;
                          obj[name] ={src : result.pageData[i].imagePath, alt : ejs.render(result.pageData[i].fieldValue, {category : req.params.category})} 
                      }
                      
                  }
  
                  
                  res.render(`${path.join(process.cwd() + &quot;/views&quot; + result.page_id.templatePath)}`, {data : obj});
              }
          }
      });
  }
  </code></pre>
  <p>and this is the output in html...
  <a href="https://i.stack.imgur.com/PkPoU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PkPoU.png" alt="This is the output image of the page " /></a></p>