-
-
Notifications
You must be signed in to change notification settings - Fork 552
Open
Labels
Description
Operating system
macOS 15.5
Eleventy
2.0.1
Describe the bug
This is empty:
{% set photoData %}
{% image
photo.data.file,
photo.data.description,
'100vw',
'photo',
true,
'object'
%}
{% endset %}
<pre>{{ photoData }}</pre>
This returns the JSON object I wanted:
<pre>
{% set photoData %}
{% image
photo.data.file,
photo.data.description,
'100vw',
'photo',
true,
'object'
%}
{% endset %}
</pre>
Reproduction steps
There quite a few moving parts, but I'll try to keep this simple.
I have an image
shortcode defined in my .eleventy.js
:
eleventyConfig.addShortcode('image', async (src, alt, sizes, className, lazyLoad, returnAs) => Tags.image(src, alt, sizes, className, lazyLoad, returnAs));
This Tags.image()
function ends with:
if (returnAs === 'html') {
return Image.generateHTML(metadata, imageAttributes)
} else if (returnAs === 'object') {
return JSON.stringify(Image.generateObject(metadata, imageAttributes))
}
Invoking the {% image %}
shortcode directly does return the JSON string I'm looking for. But for some reason, if I try to save it to a variable with a block set
, it returns nothing.
Expected behavior
I would expect both scenarios under "describe the bug" to output the same result.
Reproduction URL
No response
Screenshots
No response