Skip to content
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

Twig_Loader_String is deprecated #3424

Closed
CarsonF opened this issue Apr 21, 2015 · 12 comments
Closed

Twig_Loader_String is deprecated #3424

CarsonF opened this issue Apr 21, 2015 · 12 comments
Assignees
Milestone

Comments

@CarsonF
Copy link
Member

CarsonF commented Apr 21, 2015

Safe twig uses Twig_Loader_String which is deprecated as of 1.18.1

@GwendolenLynch GwendolenLynch added this to the Bolt 2.3 - Feature release milestone May 17, 2015
@rarila
Copy link
Contributor

rarila commented Jul 22, 2015

Some hint to solve this: twigphp/Twig#1641

@bobdenotter
Copy link
Member

Ah, that workaround seems doable.. Great example, too!

$env = new \Twig_Environment(new \Twig_Loader_Array());
$template = $env->createTemplate('Hello, {{ name }}');
echo $env->render($template, array('name' => 'Bob')); // Hello, Bob

@rarila
Copy link
Contributor

rarila commented Jul 23, 2015

@bobdenotter you only like it because of that example name ;-)

@jeroenvdgulik
Copy link

$env = new \Twig_Environment(new \Twig_Loader_Array());

This won't work as Twig_Loader_Array() expects a template as constructor parameter

@GwendolenLynch
Copy link
Contributor

@jeroenvdgulik yeah, we're just planning on implementing our own class sans a better idea.

@jeroenvdgulik
Copy link

It took me some time to figure this out so maybe this is useful for you guys. This works:

$env = new \Twig_Environment(new \Twig_Loader_Array(['my_template_name' => 'Hello, {{ name }}']));
$html = $env->render('my_template_name', array('name' => 'Bob'));

@CarsonF
Copy link
Member Author

CarsonF commented Aug 20, 2015

I think what we need to do is not have a separate safe_twig environment, but just use the Sandbox Extension they provide.

Twig functions/filters can already be defined with an is_safe option. And we can create a SecurityPolicy for more custom stuff.

@GwendolenLynch
Copy link
Contributor

Bumping this to a 2.4 milestone as @CarsonF has a branch in progress, but has too much flux for this stage in 2.3-dev.

@GwendolenLynch GwendolenLynch modified the milestones: Bolt 2.4 - Feature release, Bolt 2.3 - Feature release Oct 13, 2015
@GwendolenLynch GwendolenLynch modified the milestones: Bolt 3.1 - Feature release, Bolt 3.2 - Feature release Jul 25, 2016
@SahAssar
Copy link
Contributor

Any progress on this?

@CarsonF
Copy link
Member Author

CarsonF commented Jul 26, 2016

Nope. We could probably just copy their source.
But there's a reason they deprecated it. It's basically impossible to cache.

@GwendolenLynch
Copy link
Contributor

Ha… I've been meaning to bring this up with you for a couple of weeks, @CarsonF

It isn't super urgent right now, as it won't bite until next major anyway. But keep this open to track @SahAssar

@GwendolenLynch GwendolenLynch modified the milestones: Bolt 3.2 - Feature release, Bolt 3.3 - Feature release Oct 8, 2016
@CarsonF
Copy link
Member Author

CarsonF commented Dec 22, 2016

Fixed in 3.3 with sandbox

@CarsonF CarsonF closed this as completed Dec 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants