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

Closed
4 tasks done
reddiana opened this issue Oct 28, 2024 · 13 comments
Labels
scope: filters Additions and modifications to the search filters scope: frontmatter Anything to do with YAML frontmatter, also known as Obsidian properties 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.

@NicolaCostantino
Copy link

NicolaCostantino commented Dec 9, 2024

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.

Hi @claremacrae, is there any similar past issue/PR that I could have a look to, to figure out how the codebase works internally to purpose a PR with a consistent implementation?
Thank you!

Edit:
I already had a look at the contribution guide, I'd just like to have a reference to be consistent since it'd be a new introduction

@claremacrae
Copy link
Collaborator

Hi @NicolaCostantino - many thanks - I've spent half an hour so far going through my notes and finding-and-resurrecting my experiments from back in July... It's going to take a while longer...

Will post back either here in or in #3083 when I have something to report...

@claremacrae
Copy link
Collaborator

I have spent two hours on this, and need several more hours to give you something to start with, that does not need a lot of knowledge of the Tasks code....

Can you please give me an indication of what your timescales are, and how much time you might feasibly have to work on this?

@claremacrae claremacrae added the question Further information is requested label Dec 9, 2024
@claremacrae
Copy link
Collaborator

@NicolaCostantino Moving the discussion to the lower-level issue...

@claremacrae
Copy link
Collaborator

This is also now implemented via these PRs.

Those PRs describe the current limitations, and it needs documentation, but the basic facility is there now, and will be included in the next release - the date of which is not yet known.

@claremacrae
Copy link
Collaborator

I have just released this in Tasks 7.15.0.

The release notes have links to the relevant documentation pages.

@claremacrae claremacrae removed the status: next release Should be part of the next release label Feb 10, 2025
@reddiana
Copy link
Author

I have just released this in Tasks 7.15.0.

The release notes have links to the relevant documentation pages.

The feature you created will be incredibly useful in my journal documents. Obsidian Tasks helps me easily see what’s more important and what’s more urgent. It makes my life simpler and clearer. I truly appreciate it. Thank you so much, Mrs. Macrae!

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 scope: frontmatter Anything to do with YAML frontmatter, also known as Obsidian properties type: enhancement New feature or request
Projects
Status: 🎉 Released
Development

No branches or pull requests

3 participants