I tried to convert my theme to a tutor plugin but I came across the following error:
tutortheme/templates/dt_theme/lms/templates/ace_common/edx_ace/common/base_body.html", line 1, in template
{% load i18n %}
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'load'.
The base_body.html file contains the following:
{% load i18n %}
{% load ace %}
{% get_current_language as LANGUAGE_CODE %}
{% get_current_language_bidi as LANGUAGE_BIDI %}
{# This is preview text that is visible in the inbox view of many email clients but not visible in the actual #}
{# email itself. #}
<div lang="{{ LANGUAGE_CODE|default:"en" }}" style="
display:none;
font-size:1px;
line-height:1px;
max-height:0px;
max-width:0px;
opacity:0;
overflow:hidden;
visibility:hidden;
">
{% block preview_text %}{% endblock %}
</div>
Is there currently a way to get around this? If not, what would a solution look like?
Right. The problem is that your theme file is first rendered by Tutor (during tutor config save), before being rendered by edx-platform (at build time). And Tutor does not know anything about edx-platform-specific tags, such as {% load i18n %}.
One solution â albeit a very clumsy and inconvenient one â is to escape all {{ ... }} and {% ... %} tags: Template Designer Documentation â Jinja Documentation (3.1.x) This is the only possible solution in the case when your template file includes both Tutor and edx-platform variables.
If your template includes only edx-platform variables, then you could bypass Tutor rendering entirely. Currently there is no plug-n-play way to do that, but it should not be too hard to implement. For instance, binary files are only copied, and not rendered: tutor/env.py at 9a63dc70ceb2044ceb2027025914ab1fe7a5a025 · overhangio/tutor · GitHub
We could generalize this behaviour by creating an ad-hoc âENV_TEMPLATE_SKIP_RENDERINGâ filter. Would that work for you?
Hi, would you mind to explain your solution? Iâm having the same issue, but I doesnât seem to understand what I need to do? Sorry, Iâm new to openedx and tutor
Hi @zameel7 , do you have any problem when using your approach (with {% raw %} and {% endraw %}). When doing so I have error saying this tag (ârawâ) was not registered. Have you registered this tag somehow, somewhere?
@zameel7 , just talking about Olive version, can you please tell me: was it enough for you to wrap the jinja code with {% raw %} and {% endraw %} or⊠it was also necessary to register ârawâ tag somewhere inside openedx code? (eg in templatetags directory for corresponding app or register in any other way)?