I want to compare field 'FileSize' in my html go temple with variable 'minsize' in my code (.FileSize < *minsize). I have no idea how to do it. See below
{{ if lt .FileSize *minsize }}
<td style="color:red;">{{.FileSize}}</td>
{{else}}
<td>{{.FileSize}}</td>
{{end}}
Akama Razor tells me, that you don't need to use GO code here. it's much better to use JS in such situation.
Good luck!
s = document.getElementsByTagName('td');
for (i = 0; i < s.length; i++) {
if (parseInt(s[i].innerText) > 123) {
s[i].style = 'color:red';
}
}
<head lang="en">
<title>123</title>
</head>
<body>
<table>
<tbody>
<tr>
<td>123</td>
<td>1234</td>
</tr>
</tbody>
</table>
<script>
s = document.getElementsByTagName('td');
for (i = 0; i < s.length; i++) {
if (parseInt(s[i].innerText) > 123) {
s[i].color = '#fff';
}
}
</script>
</body>
</div>
The issue is the *
in your minsize
variable. If you are trying to dereference a pointer you have to do that in the go code, not in the template. That's why 9000
worked and the *minsize
didn't.