In this code, I am trying to set the navbar and I am defining nav
in each file because for some files, the navbar will log in or signup but for some files, it will be log out or about. No file is giving me errors except this login.html
and the error is
Error
panic: template: login.html:7: unexpected <define> in command
code
{{template "base" .}}
{{define "title"}} Log In {{end}}
{{define "body"}}
{{if .Loggedin}}
{{define "nav"}} // this is line 7 which is showing error.
<div>
<a href="/about">About</a>
<a href="/logout">Logout</a>
</div>
{{end}}
{{else}}
<h1> Log In</h1>
<p>Login to access your account.</p>
<hr>
<form action="/loggedin" method="POST" name="login" id="login">
<div>
<label for="email">Email</label>
<input type="email" name="email", placeholder="Enter your email address" required>
</div>
<div>
<label for="password">Password</label>
<input type="password" name="password", placeholder="Enter the password" required>
</div>
<div>
<input type="submit" value="Login">
</div>
</form>
{{end}}
{{end}}