If the screen is being updated, without being redrawn, in response to user activity, then what is happening behind the scenes is AJAX, where JavaScript code running on the browser is making asynchronous requests to the server, then updating the display ("DOM") accordingly. It is certainly possible to use a server-side template (output copied to a string, not printed ...) to prepare a block of HTML for delivery to the JavaScript client, which replaces a portion of the DOM with it, thus updating the display to include it.
But the admonition to "make it easy on yourself" is a good one. All of this sort of thing has been done before – a lot. Don't start from scratch.