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

Jinja2 template variables #47

Merged
merged 4 commits into from
Sep 20, 2024
Merged

Jinja2 template variables #47

merged 4 commits into from
Sep 20, 2024

Conversation

lhh
Copy link
Owner

@lhh lhh commented Jul 29, 2024

  • Use two common jinja2 "default" variable templates
  • Allow interactive input when desired
  • Require all variables detected in a template to be provided
  • Variables can be provided on the command line (just like jirate create name value name2 value2)
  • For variables provided on the command line, do not prompt user
  • Variables that are not in the template raise errors
  • I may have been hungry when writing the last test.

@lhh lhh changed the title WIP: Simple template vars Simple template vars Aug 1, 2024
@lhh lhh requested a review from compi-migui August 1, 2024 16:15
@lhh
Copy link
Owner Author

lhh commented Aug 1, 2024

Gonna merge the first 4 then resubmit this separately and more focused - they were mostly cleanups.

@lhh lhh force-pushed the simple_template_vars branch 3 times, most recently from 07534af to 6f122b7 Compare August 1, 2024 17:55
@lhh lhh closed this Aug 1, 2024
@lhh lhh deleted the simple_template_vars branch August 1, 2024 17:58
@lhh lhh restored the simple_template_vars branch August 1, 2024 17:58
@lhh lhh reopened this Aug 1, 2024
@lhh
Copy link
Owner Author

lhh commented Aug 1, 2024

Whoops, deleted it accidentally.

jirate/template_vars.py Outdated Show resolved Hide resolved
@lhh
Copy link
Owner Author

lhh commented Aug 15, 2024

I'm happy to re-push without the commit/revert, but I think that code (or something like it) may prove useful to someone else maybe, and this doesn't affect our ability to move forward.

@lhh lhh force-pushed the simple_template_vars branch 3 times, most recently from 3be0c4b to 6b1c782 Compare August 15, 2024 00:23
@lhh lhh requested a review from compi-migui August 15, 2024 00:28
jirate/jira_cli.py Outdated Show resolved Hide resolved
@lhh lhh force-pushed the simple_template_vars branch 5 times, most recently from daa9739 to 503015c Compare August 19, 2024 20:43
Jinja2 unfortunately uses glyphs that collide with the
glyphs in the JIRA markdown. Rather than escape one or
the other, for simple variable substitution, we can just
roll our own.

CPaaS uses @@variable@@, so we can as well.
Rather than maintaining our own parser, jinja2 can be used.
Miguel G. pointed out that we can simply change the glyphs used
to denote a variable declaration to avoid conflicts with Jira
syntax.

This has numerous advantages.

Contrast to 2 commits ago:
 - variable declartions -> @@var@@ to {@var@}
 - No way to specify an optional value (that's OK I think)
 - Use Jinja2 templating by passing raw text from reading
   the template instead of the dict loaded by yaml.safe_load()
This is somewhat complicated code, so be more clear with
documentation.
@lhh lhh changed the title Simple template vars Jinja2 template variables Aug 21, 2024
@lhh lhh merged commit abc51a9 into main Sep 20, 2024
4 checks passed
@lhh lhh deleted the simple_template_vars branch September 25, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants