Create dynamic HTML page using Data source

  var instform = file.load({ id: 'fileno' });
  var html = instform.getContents();
  var renderObj = render.create();
  //render create and add content 
  renderObj.templateContent = html
  //Adding ThirdParty Libraries
  renderObj.addCustomDataSource({
  format: render.DataSource.OBJECT,
  alias: "libraryPath",
  data: libraryPath //this should be an object or array by strighify version
  });
  var finalRender = renderObj.renderAsString();

Here FinalRender will be the dynamic html File

sample HTML fie to be used

<!--logo start-->
 <div class="brand">
   <a href="${libraryPath.home.link}" class="logo">
       <img src="${libraryPath.home.images.logo}" alt="">
   </a>
 </div>

Leave a comment

Your email address will not be published. Required fields are marked *