Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uncenter/eleventy-includes-async-shortcodes-demo
https://github.com/uncenter/eleventy-includes-async-shortcodes-demo
Last synced: about 8 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/uncenter/eleventy-includes-async-shortcodes-demo
- Owner: uncenter
- License: mit
- Created: 2023-05-23T12:11:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-28T13:02:49.000Z (about 1 year ago)
- Last Synced: 2023-09-28T15:14:41.179Z (about 1 year ago)
- Language: Nunjucks
- Size: 234 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### 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.
```twig
{% for i in range(0, 10) %}
42
%%
{% endfor %}
```![Normal loop](./loop.png)
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.
```twig
{% for i in range(0, 10) %}
{% include '42.njk' %}
%%
{% endfor %}
```![Loop with include](./loop_includes.png)
### 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.
```twig
{% for i in range(0, 10) %}
{% include 'boop.njk' %}
%%
{% endfor %}
```![Loop with include and async shortcode](./loop_includes_async.png)
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.
```twig
{% for i in range(0, 10) %}
{% include 'boopSync.njk' %}
%%
{% endfor %}
```![Loop with include and sync shortcode](./loop_includes_sync.png)
We see the 42 and the %% on each iteration.
### ASYNC EACH loop with include and async shortcode
![](./async_each_includes_async.png)