+1 for app.*
On 11.01.2011, at 16:36, Fabien Potencier wrote:
> Hi all,
>
> Some days ago, I've added support for global variables in Twig, and so some
> global variables are now made available in templates, like 'request',
> 'session', and 'user'.
>
> Right now, you can access them via a simple name:
>
> {{ user.username }}
> {{ session.flash('notice') }}
>
> When I've added 'user', some people wondered if it would not be better to
> "namespace" these variables to avoid problems with user-defined variables
> ('user' is probably the best example here):
>
> https://github.com/fabpot/symfony/commit/50809d2ae03d4ce0d744ff6fd2b3c515da353d6c
>
> Namespacing the variables can be achieved by prefexing them with a prefix
> (like with 'sf_*' in symfony1), or wrapping them in a global object:
>
> * Prefix:
>
> {{ sf_user.username }}
> {{ sf_session.flash('notice') }}
>
> {{ _user.username }}
> {{ _session.flash('notice') }}
>
> * Global object:
>
> {{ app.user.username }}
> {{ app.session.flash('notice') }}
>
> {{ g.user.username }}
> {{ g.session.flash('notice') }}
>
> So, the question is, which one do you prefer (keep it like it is, prefix, or
> global object)? And if you like option 2 and 3 better, which prefix/name do
> you think is best?
>
> My personal preference goes to solution 3 with 'app' as a name for the global
> object (which is by the way what people suggested in the comments of the
> commit).
>
> Fabien
>
> --
> Fabien Potencier
> Sensio CEO - symfony lead developer
> sensiolabs.com | symfony-project.org | fabien.potencier.org
> Tél: +33 1 40 99 80 80
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en