{"database": "github", "table": "issue_comments", "rows": [["https://github.com/simonw/datasette/issues/1831#issuecomment-1278198145", "https://api.github.com/repos/simonw/datasette/issues/1831", 1278198145, "IC_kwDOBm6k_c5ML8GB", 9599, "2022-10-13T21:28:30Z", "2022-10-13T21:28:30Z", "OWNER", "This has turned into a full refactor of how breadcrumbs work.\r\n\r\nI'm using my first ever Jinja macro for this - I import that at the top of `base.html` so that it will be available everywhere else:\r\n\r\n```html+jinja\r\n{% import \"_crumbs.html\" as crumbs with context %}\r\n```\r\nThe `with context` bit is needed so the macro can see the new `crumb_items()` function that I'm adding to the global template rendering scope.\r\n\r\nHere's the full content of `_crumbs.html`:\r\n\r\n```html+jinja\r\n{% macro nav(request, database=None, table=None) -%}\r\n{% set items=crumb_items(request=request, database=database, table=table) %}\r\n{% if items %}\r\n
\r\n {% for item in items %}\r\n {{ item.label }}\r\n {% if not loop.last %}\r\n /\r\n {% endif %}\r\n {% endfor %}\r\n
\r\n{% endif %}\r\n{%- endmacro %}\r\n```\r\nThis means custom template authors can use their own `_crumbs.html` template to do something different with the breadcrumbs.\r\n\r\nIn the actual templates I display breadcrumbs like this:\r\n\r\n```html+jinja\r\n{% block crumbs %}\r\n{{ crumbs.nav(request=request, database=database) }}\r\n{% endblock %}\r\n```\r\nPass `database=` to get `home / database_name` - pass `table=` as well to get `home / database_name / table_name` - if you just send `request=` you just get `home`.\r\n\r\nI've also made the default base template show the `home` breadcrumbs - other pages such as `table.html` and `row.html` can then over-ride `{% block crumbs %}` to get different breadcrumbs.\r\n\r\n\r\n", "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", 1397084281, null]], "columns": ["html_url", "issue_url", "id", "node_id", "user", "created_at", "updated_at", "author_association", "body", "reactions", "issue", "performed_via_github_app"], "primary_keys": ["id"], "primary_key_values": ["1278198145"], "units": {}, "query_ms": 2.45955100399442}