如何在不显示的情况下渲染模板


How to render a template without display

我试图找到一种方法来发送由trick模板生成的所有HTML代码在变量中,而不显示这样一个:

$var = $twig->render('pages/exports/exportLayout.html.twig'....

有没有一个禁用显示的解决方案,只在变量中显示结果?请注意,我在PHP中不使用symfony,而只使用trick模板。Thx

是的,您可以使用刚才编写的代码:$twig->render('index.html', array('the' => 'variables', 'go' => 'here'));

API表示:"返回值:字符串(渲染模板)"

只是不要回显。