Skip to content

[TwigBridge][TwigBundle] Twig serialize filter #40323

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

Merged
merged 1 commit into from
Mar 2, 2021

Conversation

jrushlow
Copy link
Contributor

@jrushlow jrushlow commented Feb 26, 2021

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #40227
License MIT
Doc PR symfony/symfony-docs#15039

Adds a new serialize filter for Twig utilizing the Serializer component. As suggested in #40227 - would allow you to pass a serialized object to the front end without needing to make an ajax call.

@jrushlow jrushlow requested a review from yceruto as a code owner February 26, 2021 23:16
@jrushlow jrushlow force-pushed the feature/twig-serialize-filter branch from ad5255f to c63e55c Compare February 27, 2021 00:24
@jrushlow jrushlow changed the title [WIP][Twig] implement twig serialize filter [Twig] implement twig serialize filter Feb 27, 2021
@jrushlow
Copy link
Contributor Author

travis failure appears to be unrelated to this PR.

@michaljusiega
Copy link
Contributor

michaljusiega commented Feb 27, 2021

Simple question. If serialize will be added, why not unserialize too?

Second question: why only objects we can serialize?

@OskarStark
Copy link
Contributor

Unserialize has not really a use case 🧐

@jrushlow jrushlow force-pushed the feature/twig-serialize-filter branch 2 times, most recently from 41337fe to a86eec5 Compare February 27, 2021 17:33
@jrushlow jrushlow requested a review from weaverryan February 27, 2021 17:33
@jrushlow jrushlow force-pushed the feature/twig-serialize-filter branch from 0cd8f34 to 46cd09d Compare February 27, 2021 18:49
@jrushlow
Copy link
Contributor Author

jrushlow commented Feb 27, 2021

For the travis failure:

1) Symfony\Bridge\Twig\Tests\Extension\SerializerExtensionTest::testContextPassedToSerializer

Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template ("[Semantical Error] The annotation "@Groups" in property Symfony\Bridge\Twig\Tests\Fixtures\extension\SerializerModelFixture::$name was never imported. Did you maybe forget to add a "use" statement for this annotation?") in "template" at line 1.

Am I missing something obvious?
doctrine/annotations dev dependency version constraint was to low for PHP8

@jrushlow jrushlow force-pushed the feature/twig-serialize-filter branch from 4b9eee6 to 663caa0 Compare February 27, 2021 21:21
@jrushlow jrushlow force-pushed the feature/twig-serialize-filter branch 2 times, most recently from cadbec7 to 67b3b2c Compare March 1, 2021 19:53
@carsonbot carsonbot changed the title [Twig] implement twig serialize filter [TwigBridge][TwigBundle] [Twig] implement twig serialize filter Mar 1, 2021
@derrabus derrabus changed the title [TwigBridge][TwigBundle] [Twig] implement twig serialize filter [TwigBridge][TwigBundle] Twig serialize filter Mar 1, 2021
@jrushlow jrushlow force-pushed the feature/twig-serialize-filter branch from 67b3b2c to 9d65355 Compare March 1, 2021 21:20
@jrushlow jrushlow requested review from weaverryan, derrabus and stof March 1, 2021 21:29
@jrushlow jrushlow force-pushed the feature/twig-serialize-filter branch from f9e3aba to abb534a Compare March 2, 2021 06:28
@jrushlow
Copy link
Contributor Author

jrushlow commented Mar 2, 2021

this should be all set now

@derrabus
Copy link
Member

derrabus commented Mar 2, 2021

Thank you @jrushlow.

@derrabus derrabus merged commit 3a92844 into symfony:5.x Mar 2, 2021
@jrushlow jrushlow deleted the feature/twig-serialize-filter branch March 2, 2021 18:11
@fabpot fabpot mentioned this pull request Apr 18, 2021
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Sep 22, 2022
… filter (94noni)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

Frontend Encore document passing data via serialize twig filter

I think this feature added in v5.3 is a great addition, specialy in this doc article
ref https://symfony.com/blog/new-in-symfony-5-3-twig-serialize-filter + symfony/symfony#40323

Cc `@jrushlow` `@weaverryan`

Commits
-------

2a1314e Frontend Encore document passing data via serialize twig filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Twig |serialize Filter for the Serializer
8 participants