yogthos / Selmer

A fast, Django inspired template system in Clojure.
Eclipse Public License 1.0
983 stars 114 forks source link

block.super doesn't work with invoking template-tags #199

Open pkozak opened 5 years ago

pkozak commented 5 years ago

I have a base template like this:

    {% block css %}
      <!-- styles -->
      {% style "/assets/bulma/css/bulma.min.css" %}
      {% style "/assets/material-icons/css/material-icons.min.css" %}
      {% style "/css/screen.css" %}
    {% endblock %}

And the child template which extends block css from base.html:

{% extends 'base.html' %}

{% block css %}
    {{ block.super }}
    {% style "/css/sample.css" %}
    <!--end style-->
{% endblock %}

The result of rendering was unexpected for me :

<!-- styles -->

<link href="/css/sample.css" rel="stylesheet" type="text/css" />
<!--end style-->

As you see, block.super was replaced with content from base block css (you can see line with comment <!-- styles --> from base.html), but styles was replaced with empty lines and that's incorrect for me.

yogthos commented 5 years ago

The block.super tag only works for static content at the moment. I probably won't have a chance to look at adding support for this in the near future, but I am open to a PR.

pkozak commented 5 years ago

Thank you for your proposition. It would be a great entertainment for upcoming holidays, but now I've critical project and I'm avoid wasting my time. Could you recommend me any solid alternative template-library?

yogthos commented 5 years ago

Hiccup is the most popular alternative, but you can also take a look at the libraries here under the "Template Lanugages" section.

If you do end up using Selmer the way to do this would be to either create a separate block, or to use an include tag with the common css in it.