{{define "recipes"}} <!DOCTYPE html> <html> {{ template "head" }} <header> <nav> <a href="/recipes">HOME</a> </nav> <h1>Recipe overview</h1> </header> <body> <main> <p>Here are the available recipes 😋🍳🍔🍕🥘</p> <input id="search" onkeyup="filter()" type="text" placeholder="Search for a recipe ..."></input> <ul id="recipes">{{range .}} <li><a href="./recipe/{{.Id}}">{{.Title}}</a></li>{{end}} </ul> </main> {{ template "footer" }} <script> function filter() { var input, query, ul, li, a, i, txtValue; input = document.getElementById('search'); query = input.value.toUpperCase(); ul = document.getElementById("recipes"); li = ul.getElementsByTagName('li'); for (i = 0; i < li.length; i++) { a = li[i].getElementsByTagName("a")[0]; txtValue = a.textContent || a.innerText; if (txtValue.toUpperCase().indexOf(query) > -1) { li[i].style.display = ""; } else { li[i].style.display = "none"; } } } </script> </body> </html> {{end}}