我不知道它不起作用。服务器环境:
Twig:3.0
PHP:7.X
nginx:1.15.11
{{ include 'Include/header.html' }}
模板文件:
|-index.html
|-content.html
|-Include
|- head.html
|- footer.html
index.php:
$loader = new Twig_Loader_Filesystem(ROOT_PATH.'/Templates');
$twig = new Twig_Environment($loader, [
'cache' => ROOT_PATH.'/Cache',
'auto_reload' => true,
'debug' => true
]);
echo $twig->render('index.html');
index.html:
{{ include 'Include/head.html' }}
<article>
body
<article>
{{ include 'Include/footer.html' }}
它不起作用,页面为空白。
答案 0 :(得分:-2)
首先,如果在开发环境中,请尝试将其注释掉
'cache' => ROOT_PATH.'/Cache',
然后出现拼写错误
{{ include 'Include/foother.html' }}
到
{{ include 'Include/footer.html' }}
我建议您尝试不首先包含任何子树枝,并首先渲染简单的1树枝。如果成功,则只需包含并重试。