rcrowe / TwigBridge

Give the power of Twig to Laravel
MIT License
894 stars 168 forks source link

String Loader #172

Open RyanThompson opened 9 years ago

RyanThompson commented 9 years ago

It would be awesome if this came packaged with a string loader version of twig as an alias.

howardroark commented 8 years ago

+1

barryvdh commented 8 years ago

What do you mean exactly? Can you give an example of what you want?

RyanThompson commented 8 years ago

string-render('{{ example_func() }}', [vars]);

I have a bound instance of the bridge using the string loader in Pyro:

https://github.com/anomalylabs/streams-platform/blob/1.0/develop/src/Support/String.php

barryvdh commented 8 years ago

StringLoader is deprecated and removed in 2.0. See https://github.com/twigphp/Twig/pull/1641

Does something like this work?

$template = Twig::createTemplate('{{ example_func() }}');
echo Twig::render($template, $vars);

I suppose it could be used to make a helper method, for Twig::renderString('{{ example_func() }}', $vars), not sure if it's needed.