1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<%!
import (
"fmt"
"strings"
)
var a int
const b = "hello, world"
func Add(a, b int) int {
return a + b
}
type S struct {
Name string
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div>
<%: func define %>
<%~ "parent template" %>
<%+ "sub template" %>
<%! go code %>
</div>
<%@ body { %>
<span>hello here</span>
<% } %>
<div>
<%== "hello" %>
<%==i 34 %>
<%==u Add(a, b) %>
<%==s user.Name %>
</div>
<div>
<% for _, user := userList { %>
<% if user != "Alice" { %>
<%= user %>
<% } %>
<% } %>
</div>
<div>
<%
a, b := 1, 2
c := Add(a, b)
%>
</div>
<div>
<%# note %>
</div>
</body>
</html>
|