Skip to content

[6.x] Keep augmentable tag results as objects inside Antlers interpolations - #15424

Open
duncanmcclean wants to merge 1 commit into
6.xfrom
asset-tag-interpolation
Open

[6.x] Keep augmentable tag results as objects inside Antlers interpolations#15424
duncanmcclean wants to merge 1 commit into
6.xfrom
asset-tag-interpolation

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where assigning the asset tag's result to a variable, like {{ img = { asset url="/img/logo.png" } }}, gave you the URL string rather than the asset, so {{ img.alt }}, {{ img.width }} and friends were empty.

This was happening because tag output inside an interpolation was reduced as if it were being rendered directly, and that path casts any object with __toString (like an Asset) to a string before the value is handed back.

This PR fixes it by leaving augmentable objects alone when they're returned from a tag inside an interpolation. The Antlers runtime already knows how to work with an Asset held in a variable, so {{ img }} still outputs the URL, while {{ img.alt }}, {{ img:width }} and looping over {{ img }} now work too.

Fixes #11257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

asset tag does not return asset object when used as "inline mode"

1 participant