I have this small code that gets rendered the first time the page loads.
Make a template, put it outside html
<body> and use that to feed handlebars. You will be able to take it, feed handlebars and append to DOM with substituted values and retrieve the template itself (you can use
<template> tag for it or
<script> and add
id attribute to reference it easily. That's how it's done on many websites.