💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
# `template_from_string` New in version 1.11: The `template_from_string` function was added in Twig 1.11. The `template_from_string` function loads a template from a string: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2</pre></div></td><td class="code"><div class="highlight"><pre>{{ include(template_from_string("Hello {{ name }}")) }} {{ include(template_from_string(page.template)) }} </pre></div></td></tr></table> Note The `template_from_string` function is not available by default. Youmust add the `Twig_Extension_StringLoader` extension explicitly whencreating your Twig environment: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2</pre></div></td><td class="code"><div class="highlight"><pre>$twig = new Twig_Environment(...); $twig-&gt;addExtension(new Twig_Extension_StringLoader()); </pre></div></td></tr></table> Note Even if you will probably always use the `template_from_string` functionwith the `include` function, you can use it with any tag or function thattakes a template as an argument (like the `embed` or `extends` tags). ### Arguments - `template`: The template