-
-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow shortcodes to return promises #429
Comments
I was able to work around this by using a custom Nunjucks tag. However, it would be more convenient if shortcodes worked with promises.
|
I agree that this absolutely should happen. I’m not sure if all of the Shortcode compatible template engines support asynchronous code like this, however. Nunjucks probably does, as you seem to have tested. Not sure about Liquid or Handlebars though. |
This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open. View the enhancement backlog here. Don’t forget to upvote the top comment with 👍! |
I just wanted to comment and add that I ran across another use case for this. I'm writing a shortcode that uses SVGO, and that library returns a promise. Here's an example from their documentation. |
I was thinking about this request (supporting promises) as well. |
Just published my first eleventy plugin today. Oh my! Can we think about how the ideal API would look like? |
Personally, I'd also see some kind of declarative API about what name the tag implements. This way, eleventy could suggest which package to install once one was removed. It's a pain point I had with WordPress (before moving off that platform). I'd envision this as an collection on 11ty.io at the very least. |
@Ryuno-Ki I ended up implementing something somewhat similar in my project. I agree that the API is a little complex here, as well as in a few other areas. In particular, I found these difficult to work with:
That being said, I don't want to sound like a complainer. Eleventy is awesome, and for the most part, it was a joy to use. 😃 |
…ey were already working in Liquid).
|
This is awesome! Thank you! |
The doc updates point to async shortcodes being added in 0.9.1 But I can't find the v0.9.1 release on github releases or npm releases, and #429 is listed in the release notes for v0.10.0 beta Might be helpful to update the following line in docs/languages/nunjucks.md
But maybe this is all pre-emptive and will get updated when v0.10.0 comes out of beta |
Ah yep sorry @KyleMit, I’ll update that to say 0.10.0. |
This was extended further in this upcoming 2.0 feature #2726 |
I'm writing a simple shortcode that hooks into the Embedly API. This function should return some HTML that can be rendered directly into my static template.
I was surprised that Eleventy doesn't support promises in shortcodes. It would be great if support for those could be added.
Here's what my shortcode function looks like for reference.
The text was updated successfully, but these errors were encountered: