I have a Jinja2 base template, base.html
, which looks like
...
{% block styles %}
<link rel="stylesheet" href="{{ PATH_TO_STYLES }}/style.css">
{% endblock %}
...
and I’d like my including templates to be able to specify that PATH_TO_STYLES
variable. As I understand it, block scoped
ought to do this, but it doesn’t seem to work. In article.html
, I have:
{% extends "base.html" %}
{% set PATH_TO_STYLES = "../.." %}
{% block styles scoped %}{{ super() }}{% endblock %}
but this does not work; the value of PATH_TO_STYLES
specified in article.html
is not substituted when the article.html
template is rendered. How am I meant to do this?