Jinja 1.2 Plans

Jinja 1.1 released, it’s arrived in debian too (Thanks Piotr Ożarowski for uploading it that quick) and I can start thinking about what to put into 1.2. Actually the plans for 1.2 exist for longer than 1.0 but implementing the Features for 1.0 and 1.1 took incredible long because more and more ideas came up.

Actually the Jinja code is quite stable by now and hopefully stable enough for the import system which will be the major change for 1.2. Basically what Jinja does by now is doing inheritance before generating the bytecode. Basically what I want to have in 1.2 is an import system so that you can import macros into a namespace and do dynamic layouts. This could slow things down a bit that’s why I want to keep the static inheritance if possible and switch to the dynamic one if necessary. Currently Jinja does that implementation switching in other situations too, like in the Jinja 1.1 shorthand block syntax.

Basically what I want it to do is on the one hand this:

{% include helpers='helpers.html' %}
{% call helpers.dialog('foo') %}
    This is the dialog text.
{% endcall %}

And on the other hand dynamic inheritance is another thing I want in Jinja:

{% if show_details %}
  {% set template_to_use='with_details.html' %}
{% else %}
  {% set template_to_use='without_details.html' %}
{% endif %}
{% extends template_to_use %}
{% block body %}content goes here{% endblock %}

Also the limitation for trans tags that simple variables must now follow variable expressions should go (currently it must be {% trans foo, bar=baz, blah=blah %} instead of {% trans foo, bar=baz, blah %} because Jinja just reuses the rule for function calls)

I guess not all of that will make it into Jinja 1.2, and maybe I come up with better ideas but that’s the plan so far.

Leave a Reply

cogitations driven by wordpress