-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TwigBundle] Make twig extension handle custom template escaping guesser #7479
Conversation
👏 |
Looks like a good addition to me. I would use a notation that would respect how we reference services elsewhere: twig:
autoescape_service: @my_service
autoescape_service_method: guess Also, beside documentation, you should add a note in the component CHANGELOG describing the new feature. |
I added the new config settings. |
Added documentation, see above |
@fabpot I would remove the
|
ping @fabpot any desicion on this? Currently its implemented that the @ is stripped. Also another question: Is there any chance of getting this PR also backported to 2.1. or 2.2. ? |
@maxbeutel no, there is no chance for this to be backported, only bug-fixes can be applied to older branches IMO we could consider to structure this similarly to what we have (ie form fields type guessers) It would be great that guessers can be classes that implement common interface and are registered as a tagged services, and passed to something like a chained guesser, then each bundle will be able to easily define its own guessers (with possibly its own escaping rules) - for now this can be little overhead, but will save us enough playground and flexibility for future |
@canni this sounds way too complicated for such a simple task. |
@canni Twig expects a callable. The goal here is simply to define a callable as |
What about the |
Let's remove the @maxbeutel After removing the |
This PR was merged into the master branch. Discussion ---------- [TwigBundle] Make twig extension handle custom template escaping guesser I wanted to add a custom template escaping guesser for twig like in http://twig.sensiolabs.org/doc/recipes.html#using-the-template-name-to-set-the-default-escaping-strategy This pull request allows you register a service id and a method as a custom guesser: twig: autoescape: my_service:guess Documentation is missing for this PR and the unit tests are not that good. I´d work on it if this PR has any chance of getting merged? | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | (missing) Commits ------- c2c1ed0 make twig extension handle custom template escaping guesser
I've made the needed changes and changed the XSD to use @maxbeutel Can you submit a PR on the documentation? Thanks. |
@fabpot I added docs here symfony/symfony-docs#2459 thanks for merging and doing the changes! |
I wanted to add a custom template escaping guesser for twig like in http://twig.sensiolabs.org/doc/recipes.html#using-the-template-name-to-set-the-default-escaping-strategy
This pull request allows you register a service id and a method as a custom guesser:
Documentation is missing for this PR and the unit tests are not that good. I´d work on it if this PR has any chance of getting merged?