Skip to content
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 array type for shortcodes #270

Closed
piedoom opened this issue Mar 27, 2018 · 5 comments
Closed

allow array type for shortcodes #270

piedoom opened this issue Mar 27, 2018 · 5 comments
Labels
done in pr Already done in a PR enhancement

Comments

@piedoom
Copy link
Contributor

piedoom commented Mar 27, 2018

I'm creating an album shortcode that contains an arbitrary amount of images. It'd be very nice to be able to just go something like:

{{ album(paths=["file1.jpg", "file2.jpg", "file3.jpg"]) }}

Because arrays are ignored, the next best solution that I can imagine is something like defining manually different amounts for different shortcodes, i.e. album2, album3, album4, and so on.

@Keats
Copy link
Collaborator

Keats commented Mar 27, 2018

Yep definitely something I want, just need to fix the markdown renderer first!

@asaaki
Copy link
Contributor

asaaki commented Mar 27, 2018

Another workaround should be to provide a splittable string and an optionally overridable separator.

{{ album(paths="file1.jpg,file2.jpg,file3.jpg", sep=",") }}

But I'd also agree that we need self-definable arrays (not only in shortcodes, but supported by tera in general).

@Keats Keats mentioned this issue May 7, 2018
@Keats Keats added the done in pr Already done in a PR label May 11, 2018
@Keats Keats closed this as completed Aug 3, 2018
@Jieiku
Copy link
Contributor

Jieiku commented May 16, 2022

Anyone know of an example Shortcode that takes an array as an argument?

I have a super neat idea for a shortcode, and passing an array to it will make things much easier.

@Keats
Copy link
Collaborator

Keats commented May 16, 2022

It should work as expected in the original comment?

@Jieiku
Copy link
Contributor

Jieiku commented May 16, 2022

YEP! it works, I made an image hover comparison shortcode: imghover

https://abridge.netlify.app/overview-images/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done in pr Already done in a PR enhancement
Projects
None yet
Development

No branches or pull requests

4 participants