JacobCoffee / niapi

Toy project to showcase Litestar, HTMX, TailwindCSS. Network Information API

Home Page:https://niapi.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhancement: Utilize Jinja loops to clean up `partial.html`

JacobCoffee opened this issue · comments

In https://github.com/JacobCoffee/niapi/blob/7fa00751763cffc18a1cc59024a999e4b5044858/app/domain/web/templates/partial.html - experiment with passing in the entire network info object and using Jinja template loops to access each member of the object.

We could cut down the LOC here from 100 to ~30

Example

<table class="min-w-full divide-y divide-gray-300 dark:divide-gray-600">
    <thead>
    <tr>
        <th
                scope="col"
                class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 dark:text-white sm:pl-6 hover:bg-neutral-900/40"
        >
            Field
        </th>
        <th
                scope="col"
                class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white hover:bg-neutral-900/40"
        >
            Value
        </th>
    </tr>
    </thead>
    <tbody>
    {% for data in network_info %}
        <tr class="hover:bg-neutral-900/40">
            <td
                    class="relative py-4 pl-4 pr-3 text-sm sm:pl-6 font-medium text-gray-900 dark:text-neutral-200"
            >
                {{ data.name }}
            </td>
            <td class="px-3 py-3.5 text-sm text-gray-500 dark:text-gray-400">
                {{ data.data }}
            </td>
        </tr>
    {% endfor %}
    </tbody>
</table>

Funding

  • Want to see an issue completed quicker? Pledge for it!
  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar