I have HTML template code like
<!doctype html>
<html>
<head>
<title>Our Funky HTML Page</title>
<meta name="description" content="Our first page">
<meta name="keywords" content="html tutorial template">
</head>
<body>
Content goes here.
</body>
</html>
I want generate a link in my html template who render this code into a new page For now I have done a function like this
function stringToHtml(htmlString: string) {
let parser = new DOMParser();
let doc = parser.parseFromString(htmlString, 'text/html');
return doc.body;
}
who take html string (my template) as argument.
In my template (where I need to render this link) I interpolate this function
function generateLink(myHtmlTemplate: string, text: string){
const page = stringToHtml(myHtmlTemplate)
return `<a href="${page}" target="_blank">${text}</a>`
}
But I don't know I can I do to open the HTML render after a click on the link