1
votes

Im writing an application using Symfony2 for the backend and backbonejs + underscore for the frontend, since I need everything to be easily crawled by the search engine I still use twig. When a template needs to be rendered live (example picture upload without reloading) then I use underscore.

<a href="{{ path('singlepost', {'postnumber': '<%= imageId %>' }) }}" target="_blank">
    <img id="lsrc<%= imageId %>" src=""  id='lazyload<%= imageId %>' class='content-bubble-img'>
</a>

Everything is working fine on img tag, when I pass a value from backbone to the template (the imageId), what doesn't work is passing the same value to the twig path() method.

Instead of returning an integer like on the img tag it returns the path localhost/app_dev.php/post/%3C%25-%20imageId%20%25%3E of course I need it to return the <%= ImageId %> value, I think twig is escaping the input in this case but verbatim(called raw before) won't work in this case

1
You fill find it there: stackoverflow.com/questions/10633676/…goto

1 Answers

0
votes

I think it's a problem of "transliteration". You can't have special characters in your url.

More details here : http://www.w3schools.com/tags/ref_urlencode.asp

Maybe the "url_encode" filter of Twig can help you : http://twig.sensiolabs.org/doc/filters/url_encode.html