To explain my needs :
- I want my users to create by themselves a "twig template" with Google Docs
- For example, if inside my user's GDocs there is {% if user.id is defind %}{{ user.name }}{% endif %}
- I want, in my Controller, to get this string ("{% if user.id is defind %}{{ user.name }}{% endif %}")
- Then check if this particular Twig string can be interpreted
- If yes, get the real value of that twig string (let's say "John")
- And then, in a the GDocs of my user, replace "{% if user.id is defind %}{{ user.name }}{% endif %}" by "John"
I absolutely need to get the final value ("John"), because GDocs just gives a method to search and replace a string (search "{% if user.id is defind %}{{ user.name }}{% endif %}", replace by "John").
So...
For each twig string that I find in their GDocs, I need to test if I can find a value for this twig.
Is there a way to "create" a twig in my Controller, replace its value by something like this ?
$myTwig = new TwigTemplate("{% if user.id is defind %}{{ user.name }}{% endif %}");
$myUserName = $this->render($myTwig, array("user" => $user")
Thank you in advance !