noiselabs / SmartyBundle

Smarty3 template engine bundle for Symfony
http://smartybundle.readthedocs.io/
GNU Lesser General Public License v3.0
51 stars 36 forks source link

Add support for Expressions within templates #37

Closed mlabrum closed 10 years ago

mlabrum commented 10 years ago

This adds support for using symfony Expressions.

This class is pretty much a copy of https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php

This allows you to use expressions with the security extension http://symfony.com/doc/current/book/security.html#book-security-template-expression

{if '"ROLE_ADMIN" in roles or (user and user.isSuperAdmin())'|expression|is_granted }
Hi Admin!
{/if}
vitorbrandao commented 10 years ago

Merged. Thank you @mlabrum!

vitorbrandao commented 10 years ago

Added an example to the documentation: https://smartybundle.readthedocs.org/en/latest/extensions.html#complex-access-controls-with-expressions