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

Do not JSON encode stringable values #171

Merged
merged 1 commit into from
May 3, 2022

Conversation

jderusse
Copy link
Member

@jderusse jderusse commented Apr 21, 2022

When using stimulus_controller with values generated by twig, the values are converted to JSON. Which prevent the following code working out of the box.

{% set tooltip %}
  Hello <strong>{{ name }}</strong>
{% endset %}

<div {{ stimulus_controller('tooltip', {html: true, title: tooltip}) }}>
  title
</div>

Because the content of the variable tooltip is an \Twig\Markup object.

This PR stringifies values instead of json_encoding.

@weaverryan
Copy link
Member

That's a nice catch - thank you Jérémy!

@weaverryan weaverryan merged commit 8e3d69d into symfony:main May 3, 2022
@weaverryan weaverryan added the Bug Bug Fix label May 3, 2022
@weaverryan weaverryan mentioned this pull request May 3, 2022
@jderusse jderusse deleted the stimulus-value-json branch May 3, 2022 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants