How can I use a html template as an "innerHTML"?

I am trying to fetch more detailed data and show this info ad-hoc in the same window. On bigger screens. On smaller screens I want to hide the list and show detailed when double click.

To illustrate my goal, i have done a very simple write to innerHTML. (screens above 1800px shows both list and card)

const selected = table.getElementsByClassName('selected')
table.onclick = sel;
function sel(row) {
  if (selected[0]) selected[0].className = ''; = 'selected';
  table.className = '';

function add2card(text){
	document.getElementById("add2card").innerHTML = text;

I have found three ways to do this.

  1. Fetch data via AJAX ( do not know how to parse and format the json )
  2. Fetch the normal way and show in an iFrame
  3. Store all content in the list (some data hidden) and do basically as above.

In my imagination there is a way to get a Go html template to act as a innerHTML.

OR a way to parse json and deliver a html as a value to insert as a innerHTML.

OR something like this:
data := tpl.ExecuteTemplate(w, page, data)

Any clue how to avoid AJAX is welcome!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.