Skip to content

uncenter-archive/eleventy-includes-async-shortcodes-demo

Repository files navigation

Normal loop

In the normal loop section, we are doing a simple loop from 0 to 10, and printing the number 42 and %% on each iteration.

{% for i in range(0, 10) %}
    42
    <p>%%</p>
{% endfor %}

Normal loop

This works as expected, and the output is correct.

Loop with include

If we include the 42.njk file, which just contains '42', the output is also correct.

{% for i in range(0, 10) %}
    {% include '42.njk' %}
    <p>%%</p>
{% endfor %}

Loop with include

Loop with include and async shortcode

If we include the boop.njk, which contains {% beep %} (an async shortcode that returns '42'), and then do the loop, the output is incorrect.

{% for i in range(0, 10) %}
    {% include 'boop.njk' %}
    <p>%%</p>
{% endfor %}

Loop with include and async shortcode

The 42 is not outputted, and the %% is also not outputted.

Loop with include and sync shortcode

However, if we include the boopSync.njk, which contains {% beepSync %} (a sync shortcode that returns '42'), and then do the loop, the output is correct.

{% for i in range(0, 10) %}
    {% include 'boopSync.njk' %}
    <p>%%</p>
{% endfor %}

Loop with include and sync shortcode

We see the 42 and the %% on each iteration.

ASYNC EACH loop with include and async shortcode

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors