- With issues:
- Gin do not support javascript ?
- If I added javascript into the html template file ,It will not appear in the view ?
Description
If I added javascript into the html template file ,It will not appear in the view ?
How to reproduce
{{define "posts/index.html"}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>posts/index</title>
</head>
<body>
<h1>{{.title}}</h1>
<h3>{{.MyParam}}</h3>
<h3>{{.JsonParam}}</h3>
<h3>{{.JsonParam.a}}</h3>
<div id="demo"></div>
{{/*
<script>
var x;
var txt="";
var person={{.JsonParam}}
for (x in person){
txt=txt + person[x].a;
}
document.getElementById("demo").innerHTML=txt;
</script>
*/}}
</body>
</html>
{{end}}
Expectations
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>posts/index</title>
</head>
<body>
<h1>title</h1>
<h3>xxx</h3>
<h3>yyy</h3>
<h3>zzz</h3>
<div id="demo"></div>
<script>
var x;
var txt="";
var person={x:1,y:2}
for (x in person){
txt=txt + person[x].a;
}
document.getElementById("demo").innerHTML=txt;
</script>
</body>
</html>
Actual result
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>posts/index</title>
</head>
<body>
<h1>title</h1>
<h3>xxx</h3>
<h3>yyy</h3>
<h3>zzz</h3>
<div id="demo"></div>
</body>
</html>
If I added javascript into the html template file ,It will not appear in the view ?
Environment
- go version:latest
- gin version (or commit ref):
- operating system:windows10
Comment From: RedCrazyGhost
Please add the expected effect and actual effect, at present, I can't judge your needs by looking at the issue.
Comment From: devgis
Please add the expected effect and actual effect, at present, I can't judge your needs by looking at the issue.
Hi,Edited . As you can see in the Actual result the "script" codes were missed.
Comment From: RedCrazyGhost
HTML natively supports