Hey guys-
I've another "best-practice" question for Symfony2. What's the best
way to inject variables into a layout? The topic was covered briefly
earlier (http://groups.google.com/group/symfony-devs/browse_thread/
thread/e46e5bb74fc3a78b/d2aefa40603d1dc6?
lnk=gst&q=layout#d2aefa40603d1dc6) where Thibault came to the
conclusion that a template helper is necessary (I also don't see
another way).
Suppose I have a breadcrumb that's a service (and is Countable). I'd
like, in Twig, to be able to do the following:
<?php if (count($breadcrumbs)): ?>
<div id="breadcrumbs">
<?php echo $breadcrumbs ?>
</div>
<?php endif; ?>
If I had access to the breadcrumbs service, then the above is trivial
in Twig. However, if I need to use an extension to get the service (if
that's even the best option), I'm not sure if I can use the extension
to retrieve and then loop through a return value (i'm ignorant about
Twig in this regard). Is there an event for injecting variables when
the view is rendered (the equivalent to template.filter_parameters in
sf1) - I don't see one. If not, is there a specific reason why that
type of event is a bad pattern?
Thanks!
--
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