obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.46k stars 231 forks source link

Support for Using YAML Front Matter Values as Variables in Queries #3154

Open reddiana opened 4 hours ago

reddiana commented 4 hours ago

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

🔖 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.

claremacrae commented 3 hours ago

Yes this would be good to have.

I think I see this as a duplicate of:

claremacrae commented 3 hours ago

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 commented 3 hours ago

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 commented 3 hours ago

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 commented 3 hours ago

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.