mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
Merge pull request #107 from h-sphere/feat/template-expose-properties
feat: template can now access file properties
This commit is contained in:
commit
77a4f7109e
7 changed files with 19 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
# 0.28.4 (2025-03-15)
|
||||
- Feat: Template view can now access file properties
|
||||
# 0.28.3 (2025-03-15)
|
||||
- Fix: Filename field in files column no longer truncates name after dot
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,19 @@ Data from the query is exposed as `data` variable.
|
|||
|
||||
Learn more about handlebars syntax [in their official documentation](https://handlebarsjs.com/guide/).
|
||||
|
||||
## Variables
|
||||
The following variables are exposed
|
||||
| Variable | Description |
|
||||
| ---------- | -------------------------------------------------- |
|
||||
| data | Array of the data returned by the SELECT statement |
|
||||
| columns | Array of column names |
|
||||
| properties | Object containing all properties of the file |
|
||||
|
||||
|
||||
## Example
|
||||
```sql
|
||||
TEMPLATE
|
||||
Current Path: {{properties.path}}
|
||||
{{#each data}}
|
||||
<div>{{path}}</div>
|
||||
{{/each}}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "sqlseal",
|
||||
"name": "SQLSeal",
|
||||
"version": "0.28.3",
|
||||
"version": "0.28.4",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Use SQL in your notes to query your vault files and CSV content.",
|
||||
"author": "hypersphere",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "sqlseal",
|
||||
"version": "0.28.3",
|
||||
"version": "0.28.4",
|
||||
"description": "A plugin for Obsidian that allows you to run SQL queries on your notes.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ export class CodeblockProcessor extends MarkdownRenderChild {
|
|||
}
|
||||
|
||||
const { data, columns } = await this.db.select(transformedQuery, variables)
|
||||
this.renderer.render({ data, columns, flags: this.flags })
|
||||
this.renderer.render({ data, columns, flags: this.flags, frontmatter: variables })
|
||||
} catch (e) {
|
||||
this.renderer.error(e.toString())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ export class TemplateRenderer implements RendererConfig {
|
|||
|
||||
render(config: TemplateRendererConfig, el: HTMLElement) {
|
||||
return {
|
||||
render: ({ columns, data }: any) => {
|
||||
render: ({ columns, data, frontmatter }: any) => {
|
||||
el.empty()
|
||||
|
||||
// Seems to be the only way to render handlebars into DOM. Don't like it but what can we do.
|
||||
el.innerHTML = config.template({ data, columns })
|
||||
el.innerHTML = config.template({ data, columns, properties: frontmatter })
|
||||
},
|
||||
error: (error: string) => {
|
||||
displayError(el, error)
|
||||
|
|
|
|||
|
|
@ -52,5 +52,6 @@
|
|||
"0.28.0": "0.15.0",
|
||||
"0.28.1": "0.15.0",
|
||||
"0.28.2": "0.15.0",
|
||||
"0.28.3": "0.15.0"
|
||||
"0.28.3": "0.15.0",
|
||||
"0.28.4": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue