1``template_from_string`` 2======================== 3 4.. versionadded:: 1.11 5 The ``template_from_string`` function was added in Twig 1.11. 6 7The ``template_from_string`` function loads a template from a string: 8 9.. code-block:: jinja 10 11 {{ include(template_from_string("Hello {{ name }}")) }} 12 {{ include(template_from_string(page.template)) }} 13 14.. note:: 15 16 The ``template_from_string`` function is not available by default. You 17 must add the ``\Twig\Extension\StringLoaderExtension`` extension explicitly when 18 creating your Twig environment:: 19 20 $twig = new \Twig\Environment(...); 21 $twig->addExtension(new \Twig\Extension\StringLoaderExtension()); 22 23.. note:: 24 25 Even if you will probably always use the ``template_from_string`` function 26 with the ``include`` function, you can use it with any tag or function that 27 takes a template as an argument (like the ``embed`` or ``extends`` tags). 28 29Arguments 30--------- 31 32* ``template``: The template 33