On Wednesday, 20 July 2011 at 18:04, zgoniaiko wrote:
> hi to all.
> 
> currently we can specify route as annotation like
> 
> * @Route("/{company}/{location}/{id}/{position}", name="job_show", 
> defaults={"company"="noname", "location"="undefined", "position"="undefined"} 
> )
> 
> and in the template it will be like
> <a href="{{ url('job_show', { 'company' : job.companySlug, 'location': 
> job.locationSlug, 'id' : job.id, 'position': job.positionSlug }) }}">
>  {{ job.position }}
> </a>
You could write your own Twig extension to do this pretty easily, but I don't 
know of anything built-in. 

Make a new class with a method that returns the URL, then add it to the 
services: section of your config.yml, with the twig.extension tag and the URL 
router as an injected dependency. 

This is _completely untested_ code, just off the top of my head, but it should 
give you a reasonable starting point:
https://gist.github.com/1095423

Obviously you'll need to change the namespace name to suit. :)

-- 
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

Reply via email to