Skip to content

feat: support reusable Nunjucks templates via vault .njk files #197

@victoraraujo105

Description

@victoraraujo105

Problem

The TEMPLATE renderer currently requires the full template to be written inline in every code block. Users who have multiple queries with similar table layouts (e.g. task lists with external/internal links, status columns) must duplicate the entire template in each block. This leads to:

  • Significant boilerplate in notes with multiple queries
  • Difficult maintenance when the template design changes (must update every copy)
  • No way to share templates across notes

Proposed Solution

Allow the TEMPLATE renderer to resolve {% include %} and {% from ... import %} directives against .njk files stored in the Obsidian vault.

Usage examples

Include a full template:

```sqlseal
TEMPLATE
{% include "_templates/task-table.njk" %}

SELECT task_id, title, state FROM files WHERE ...
```

Import macros for composable templates:

```sqlseal
TEMPLATE
{% from "_templates/macros.njk" import extLink, intLink %}
<table>
{% for row in data %}
<tr>
  <td>{{ extLink(row.url, row.id) }}</td>
  <td>{{ intLink(row.title) }}</td>
</tr>
{% endfor %}
</table>

SELECT ... FROM files WHERE ...
```

Implementation

This feature is implemented across two stacked PRs:

  1. feat: replace Handlebars with Nunjucks in TEMPLATE renderer #198 — Replace Handlebars with Nunjucks in TEMPLATE renderer (prerequisite)
  2. feat: add VaultLoader for reusable Nunjucks templates in TEMPLATE renderer #199 — Add VaultLoader for reusable Nunjucks templates via .njk vault files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions