I want to generate a template html file, based on variable name (which will be changing dynamically based on user input) the title and some other variable names will be replaced from user input. How to achieve this?
If I understood your problem, you have an application, from which you are taking inputs from users to create an HTML template.
You can use javascript string literals
createHTMLTemplate(userInput){
return `<!DOCTYPE html>
<html>
<head>
<title>${userInput.title}</title>
</head>
<body>
<h1 style="background-color: red;">Hello World!</h1>
<p>${userInput.anyothervariable}</p>
</body>
</html>
`
}