Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support placeholders like '{{query.file.path}}' in queries (#2254)
* feat: @ bring changes from bleeding-edge * vault: Add sample file demonstrating {{query.file.path}} etc * docs: Update docs on finding tasks in current file * docs: Fix typo in 'How to get tasks in current file' * test: Copy in MustacheExperiments.test.ts from claremacrae fork Copied from https://github.com/claremacrae/obsidian-tasks/blob/ae657e0c09b6a040b9a94e81a2b6478a1828c7e6/tests/Query/MustacheExperiments.test.ts * test: Rename MustacheExperiments.test.ts to ExpandTemplate.test.ts * test: Generate table of query.file values, for use in docs * docs: Fix column alignment in Quick Reference markdown source * docs: Add {{query.file.path}} etc to Quick Reference * docs: Interim commit of templating documentation * fix: Query.explainQuery() reports any error message, to avoid misleading results. * test: Show explanation of instructions using templating. * docs: Update 'Explaining Queries.md' to explain templating * docs: Add 'Checking template variables' to Templating.md * docs: Remove some clutter from early experiments * docs: Record the name of the templating library used. * docs: Add "Comments" plugin to track notes to track my feedback * docs: Interim commit on documentation templating code * test: Show the output when an invalid template variable is used. * docs: markdownlint removed stray whitespace at end of snippets * test: Remove 'explain' instruction which is not needed where snippet is used * docs: Document how invalid template variables are handled * docs: Rename Templating to Placeholders in documentation * refactor: . Rename expandMustacheTemplate() to expandPlaceholders() * refactor: . Rename ExpandTemplate.ts to ExpandPlaceholders.ts * test: . Rename ExpandTemplate.test.ts to ExpandPlaceholders.test.ts * refactor: Move ExpandPlaceholders.ts to src/Scripting/ * tests: . Move ExpandPlaceholders.test.ts to tests/Scripting/ * test: - Reduce scope of a variable in ExpandPlaceholders.test.ts * test: t Add test for expanding placeholders with no query location supplied * fix: Replace 'template' with 'placeholder' in an error message * test: Capture current behaviour: Query.source still has placeholders * test: Show that filters have placeholder expanded, and rename test * refactor: - Remove Query.rawSource as it was same as Query.source * test: Show behaviour when invalid placeholder is used * fix: Update vocabulary: template -> placeholder in error message. * test: Move placeholder tests to parsing section * fix: Remove reference to Mustache library in error messages * docs: Update error text in Placeholders.md - via mdsnippets * comment: Correct function name in TODO to expandPlaceholders() * test: Remove a test that now serves no value * docs: Convert 'templating' vocabulary to 'placeholders' * test: Remove a reference to templating, in approved filenames * docs: Remove a reference to templating, in approved filenames * comment: Convert 'templating' vocabulary to 'placeholders' in Query.ts * refactor: - Extract method Query.expandPlaceholders() * refactor: . inline makeQueryContext() * jsdoc: Document new functions and types * refactor: . Move QueryContext to Scripting/ directory from lib/ * jsdoc: Delete some out-of-date comments and move mustache link to ExpandPlaceholders.ts * test: Add comments to give 2 tests some structure * test: Add another test showing unknown property errors are displayed * refactor: Move the code for improving Mustache errors to ExpandPlaceholders.ts * comment: Convert 'template' vocabulary to 'placeholders' in ExpandPlaceholders.ts * refactor: . Extract variable source * refactor: . Add source parameter to Query.expandPlaceholders() * refactor: - Show user the exact line with unrecognised placeholder(s) * refactor: - Slightly more general error text in expandPlaceholders() * test: - Increase scope of path variable, to allow re-use * test: - Confirm that mustache only does expansion if {{ is in the input * refactor: - Indent user inputs in error messages, for readability * docs: Update Error-checking section for better messages * docs: Near finalisation of Placeholders.md * docs: Document basic use of placeholders in Filters page * test: Add sample file 'a/b.md' to allPathsAndHeadings() - needed to demo placeholders in docs * test: Add examples of placeholders in custom filters * test: Add example of placeholders in custom groups * docs: Update machined-generated examples in docs for placeholders * docs: Document basic use of placeholders in Grouping page * docs: Document placeholders in custom filters and groups * docs: Add query properties and placeholders to Introduction * vault: Remove "Comments" plugin as no longer needed --------- Co-authored-by: Clare Macrae <[email protected]>
- Loading branch information