I am trying to render an html template
context.HTML(http.StatusOK,
"my_html_template.html",
information)
where my_html_template.html
has content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My HTML page</title>
</head>
<body>
Please wait. Do not push back or refresh
</body>
<script>
{{if eq .Action "form"}}
var form = "{{.PgData}}";
var elem=document.createElement("div");
elem.innerHTML=form;
document.body.appendChild(elem);
elem.firstChild.submit();
{{end}}
</script>
</html>
I cannot understand how can I render this page with inline JS. Rendered page has <script>
and all the js as html. Final html page looks like this. Please note: this is how it looks to end user(not from terminal).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Page</title>
</head>
<body>
Please wait. Do not push back or refresh
</body>
<script>
var form = "<form>....</form>";
var elem=document.createElement("div");
elem.innerHTML=form;
document.body.appendChild(elem);
elem.firstChild.submit();
</script>
</html>