Let favorite queries use Jinja2 templates - #2085
Open
rolandwalker wants to merge 1 commit into
Open
Conversation
rolandwalker
force-pushed
the
RW/jinja2-favorite-queries-optional-parameters
branch
from
August 3, 2026 11:04
949c9be to
7e5d868
Compare
allowing optional arguments and control blocks in favorite queries.
Include completions for Jinja2 key names. Supporting the completions is
quite a bit more code than the core functionality! Completions also
can only be offered if the key name is referred to explicitly in the
template (not merely iterated over, which is technically possible).
Extensively update the config file and internal helpdoc with examples
and notes.
It seems arbitrary to choose whether Jinja2 templates are processed
before or after the legacy positional arguments are substituted. I
chose Jinja2 before positional. The agent hacked together a UUID-based
solution for this, which may not be pretty.
There is one regression: whereas a positional argument could previously
freely begin with the dash character, that can now be ambiguous with the
--key=value syntax. The solution is to disambiguate by putting such
positional values after a "--":
/f query --key=value -- --ambiguous-positional-value--
This should be rare enough that the regression is worth the new feature.
This adds a Jinja2 direct dependency to the project. It was already a
transitive dependency via altair if mycli was installed with dataframe
support.
rolandwalker
force-pushed
the
RW/jinja2-favorite-queries-optional-parameters
branch
from
August 3, 2026 18:09
7e5d868 to
a4acc39
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Let favorite queries use Jinja2 templates, allowing optional arguments and control blocks in favorite queries.
Include completions for Jinja2 key names. Supporting the completions is quite a bit more code than the core functionality! Completions also can only be offered if the key name is referred to explicitly in the template (not merely iterated over, which is technically possible).
Extensively update the config file and internal helpdoc with examples and notes.
It seems arbitrary to choose whether Jinja2 templates are processed before or after the legacy positional arguments are substituted. I chose Jinja2 before positional. The agent hacked together a UUID-based solution for this, which may not be pretty.
There is one regression: whereas a positional argument could previously freely begin with the dash character, that can now be ambiguous with the
--key=valuesyntax. The solution is to disambiguate by putting such positional values after a--:This should be rare enough that the regression is worth the new feature.
This adds a Jinja2 direct dependency to the project. It was already a transitive dependency via altair if mycli was installed with dataframe support.
Fixes #1871
Edit: it looks like there is a bug here in that we determine that a key is unused unless it is referred to explicitly. That logic should apply to completions only. Will fix, but it is a real edge case, and this PR is still reviewable.Fixed.Checklist
changelog.mdfile.AUTHORSfile (or it's already there).