Closed simonw closed 4 years ago
Prior art: datasette-template-sql
: https://github.com/simonw/museums/blob/18c797958e98da5b21d1993b22ec89c5e9fccb1d/templates/row-browse-museums.html#L68-L78
<section class="section nearby-section">
{% for museum in sql("""
select *, haversine(latitude, longitude, :latitude, :longitude, 'mi') as distance_mi
from museums
where id != :id
and permanently_closed is null order by distance_mi limit 3
""", {
"latitude": museum.latitude,
"longitude": museum.longitude,
"id": museum.id
}) %}
Exposing graphql to templates means custom templates will be able to populate their context using a query embedded in the template itself - something like this: