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

Twig filter access to serializer #62

Merged
merged 5 commits into from
Dec 22, 2011
Merged

Conversation

jonotron
Copy link
Contributor

I've created a very basic twig extension that provides "wrapper" access to the serializer service via a twig filter.

It allows for {{ Entity | serialize | raw }} inside twig templates

I'm not sure if I need to setup some other config, or make this optional somehow. Suggestions/comments welcome.

*
* Basically provides access to JMSSerializer from Twig
*/
class Serializer extends \Twig_Extension {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you suffix this class with "Extension", i.e. "SerializerExtension"?

@schmittjoh
Copy link
Owner

Thanks for this patch.

Could you clean up your commits a bit to follow the Symfony2 coding style (especially 4 spaces for indentation)?

{
$this->mockSerializer = $this->getMock('JMS\SerializerBundle\Serializer\SerializerInterface');
}
public function testSerialize()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing empty line between the methods, and the indentation is wrong

@jonotron
Copy link
Contributor Author

Thanks for the feedback. Suggested coding standards changed, and naming fixed. I've also added a short bit of documentation to the main doc file.

schmittjoh added a commit that referenced this pull request Dec 22, 2011
Twig filter access to serializer
@schmittjoh schmittjoh merged commit bf10c3e into schmittjoh:master Dec 22, 2011
@schmittjoh
Copy link
Owner

Thanks, merged.

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.

4 participants