Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for using YAML front Matter Values as Variables in Queries [via placeholder values, without the need for 'filter by function'] #3154

Open
4 tasks done
reddiana opened this issue Oct 28, 2024 · 6 comments
Labels
scope: filters Additions and modifications to the search filters type: enhancement New feature or request

Comments

@reddiana
Copy link

⚠️ Please check that this feature request hasn't been suggested before.

  • I searched previous Ideas in Discussions didn't find any similar feature requests.
  • I searched previous Issues didn't find any similar feature requests.
  • I am only requesting a single feature. Multiple changes should be split into individual requests, with links between them.
  • I believe my requested feature will be generally applicable to other users, not just me: it is not uniquely tied to my personal workflow.

🔖 Feature description

I would like to suggest a feature that I believe could enhance the plugin's functionality. Specifically, I'm interested in being able to use values defined in the YAML front matter as variables within task queries in the same file.

For example, if I have a YAML front matter entry and a query like this:


---
workdate: 2023-04-01
---

```tasks
due before <YAML front matter's workdate>
```
or
```tasks
done before <YAML front matter's workdate>
```

✔️ Solution

In my use-case, <YAML front matter's workdate> would dynamically reference the workdate value specified in the YAML section of the same file. This would allow for more flexible and context-aware task filtering based on metadata defined in the file.

❓ Alternatives

No response

📝 Additional Context

If this functionality were implemented, it would significantly expand the versatility of the Tasks plugin. Users could create highly customizable templates, dynamically adjusting task queries based on file-specific YAML values. This capability would make it possible to design and maintain templates that automatically adapt to various contexts, reducing the need for manual adjustments and increasing consistency. Such a feature would not only streamline task management but also enable more advanced and reusable workflows for users who rely on templating.

Thank you for considering this request.

@reddiana reddiana added the type: enhancement New feature or request label Oct 28, 2024
@claremacrae claremacrae added the scope: scripting Issues to do with custom filters, custom sorting and similar label Oct 28, 2024
@claremacrae
Copy link
Collaborator

Yes this would be good to have.

I think I see this as a duplicate of:

@claremacrae
Copy link
Collaborator

That other issue does require understanding ‘filter by function’ so is a little more advanced that the examples that you give.

But the example you give is rather more error prone in that not all users format their dates in the same way in YAML.

@reddiana
Copy link
Author

I apologize for not noticing this earlier.
I have reviewed the following documentation:
Obsidian Properties Limitations.

I look forward to the implementation of query.file.property() and hope it will support placeholders in the future.

Thank you for your time and effort.

@claremacrae
Copy link
Collaborator

Yes, that issue mentioned in the limitations is the same one I linked to above.

I can see how the connection was not obvious.

Once query.file.properties existed it would automatically be available in placeholders, although I would still worry about date formats.

@reddiana
Copy link
Author

Thank you for your response. I would also like to mention that Tasks has been incredibly helpful in both my personal and professional life. Since a similar issue has already been submitted, please feel free to close this issue.

@claremacrae claremacrae changed the title Support for Using YAML Front Matter Values as Variables in Queries Support for using YAML front Matter Values as Variables in Queries [via placeholder values, without the need for 'filter by function'] Oct 28, 2024
@claremacrae claremacrae added scope: filters Additions and modifications to the search filters and removed scope: scripting Issues to do with custom filters, custom sorting and similar labels Oct 28, 2024
@claremacrae
Copy link
Collaborator

Thank you for your response. I would also like to mention that Tasks has been incredibly helpful in both my personal and professional life.

You're very welcome - I'm glad it's been useful.

Since a similar issue has already been submitted, please feel free to close this issue.

Actually, it's proposing to implement a feature which is useful for those who do not know Javascript, so I've modified the title to show how it is different from #3083, and will keep it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: filters Additions and modifications to the search filters type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants