Skip to content

Instantly share code, notes, and snippets.

@jfjensen
Created October 18, 2023 10:22
Show Gist options
  • Save jfjensen/4c1041ee48a65c58ee27b1480443c695 to your computer and use it in GitHub Desktop.
Save jfjensen/4c1041ee48a65c58ee27b1480443c695 to your computer and use it in GitHub Desktop.
A Jinja template used to dynamically create an HTML table to display a list of users for a Litestar app
<!DOCTYPE html>
<html lang="en">
<head>
<title>User listing</title>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h1>User listing</h1>
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>Email</th>
</tr>
{% for user in users %}
<tr>
<td>{{user.name}}</td>
<td>{{user.age}}</td>
<td>{{user.email}}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment