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

feat: expose integer Tutor version parts to templates #1060

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kdmccormick
Copy link
Collaborator

@michaelwheeler
Copy link
Contributor

For some context, this is related to a question that I brought up during the Tutor Users' Group about writing plugins that support multiple Tutor versions. We're currently doing something along the lines of...

{% if TUTOR_VERSION.startswith("14.") %}
# Do something for Tutor v14 only...
{% else %}
# Do something for Tutor versions after 14...
{% endif %}

But having major/minor/patch versions available to the context as integers would allow more precision and flexibility.

@kdmccormick kdmccormick self-assigned this May 15, 2024
@regisb
Copy link
Contributor

regisb commented Jun 10, 2024

@michaelwheeler I'd like to understand better your use case. Have you considered having multiple branches for your plugin, one for every major release?

@michaelwheeler
Copy link
Contributor

Have you considered having multiple branches for your plugin, one for every major release?

In our team, managing multiple branches for our plugins felt like more overhead than adding an occasional conditional. We also think it will slightly simplify the process of upgrading to a newer named release.

@arbrandes
Copy link

I think this would useful to have as an option for plugin authors, particularly for cases where the plugins don't change that much between releases.

@regisb
Copy link
Contributor

regisb commented Jun 14, 2024

Right. I'm still not sure if it makes sense to add these settings to Tutor core. You do know that you could define these variables in your own plugin by adding a callback to the ENV_TEMPLATE_VARIABLES filter, right?

@michaelwheeler
Copy link
Contributor

You do know that you could define these variables in your own plugin by adding a callback to the ENV_TEMPLATE_VARIABLES filter, right?

I didn't know that!

It still feels to me like Tutor should provide the variable, since the version is a property of Tutor itself, but if that's undesirable for other reasons then maybe ENV_TEMPLATE_VARIABLES can get me where I need to go.

tutor/env.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants