Skip to content
This repository

Add a "with" tag #719

Open
fabpot opened this Issue May 07, 2012 · 7 comments

6 participants

Fabien Potencier Pierre Minnieur Mark Story René Bakx Christophe Coevoet Berny Cantos
Mark Story

I think this make sense even if its just to improve compatibility with jinja's features. Besides that point, its a useful feature for templates created by people without full control over the containing template context.

René Bakx

Sounds like something that a former colleague of mine created for our drupal 6 & 7 version of twig.

https://github.com/renebakx/twig-for-drupal/blob/master/TFD/TokenParser/With.php

Still using the {% with construction in my current D7 twig templates.

Christophe Coevoet

@renebakx Please read the Jinja doc linked in the issue. It is a different meaning than your with implementation (which looks like the Javascript with keyword and would be quite hard to implement given that foo.bar can mean 5 different way to access bar in foo)

Berny Cantos

What's the status on this one? I have implemented Jinja's "with" tag support, but I don't think it's optimal. It saves the current $context inside itself with an internal index and pops it when the block ends. I can do a PR if there's any interest.

Christophe Coevoet
stof commented April 11, 2013

@xphere this is already how Twig saves the context in for loops, so it could be done for with too. Please open the PR.

Berny Cantos
xphere commented June 12, 2013

Any idea how to improve #1054? @stof @fabpot @pminnieur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.