Second forloop.counter does not print anything on screen

1

I am building a carousel of images using Foundation Orbit, for the part of the bullets I have an error when using two forloop.counter tags, I need them to print the carousel element number on the screen, one in "Humanized" form and the other in full, but it happens that it does not print anything on the screen:

Here is the code that I am using in my template.

<nav class="orbit-bullets">
    {% for affiliation in affiliations %}
        <button {% if forloop.first %}class="is-active"{% endif %} data-slide="{{ forloop.counter0 }}">
            <span class="show-for-sr">
                {% blocktrans %}{{ forloop.counter0|ordinal }} slide details.{% endblocktrans %}
            </span>
            {% if forloop.first %}
                <span class="show-for-sr">{% trans 'Current Slide' %}</span>
            {% endif %}
        </button>
    {% endfor %}
</nav>

As you can see the idea is to print 3rd slide details. and instead of this I only print the fixed string.

When I remove the additional tag ordinal it turns out that I do not have a number, so I deduce that the problem is not humanizing, the problem is printing the number:

    
asked by SalahAdDin 11.02.2016 в 20:47
source

1 answer

5

According to the blocktrans documentation, to access attributes of objects or use filters you have to associate the expression to a local variable to the block:

{% blocktrans with counter=forloop.counter0|ordinal %}{{ counter }} slide details.{% endblocktrans %}
    
answered by 12.02.2016 / 00:38
source