Override template from plugin


Is it possible to override a Tutor template from a plugin?

More concretely, I’m just trying to enable HTTP2 on nginx when SSL is enabled, and right now the only option I see would be to fork Tutor and change the nginx template there, which is far from optimal.

Furthermore, I can not think of any downside of enabling it by default on Tutor. Is there any reason it is not?


I think you’re right. Would you like to make a pull request? I’ll gladly examine it.

Would it be sufficient to change template_roots.append(plugin.templates_root) to template_roots.insert(0, plugin.templates_root) in tutor/env.py? Then a plugin can set templates and create a template with the same path as the one you want to override?

Hmmm… :thinking: I… guess so? But I don’t want to encourage people to override whole templates. This makes it much more difficult to upgrade, as your overridden file needs to backport the upstream changes.

Instead, I’d like to suggest that you let me know about additional {{ patch(...) }} statements that you would like added to the base Tutor templates. This makes it easier for the whole community to customize their platforms.