1
この小さな変更をしようとすると苦労しています...viewsディレクトリにあるが別のディレクトリの中にあるレンダリングテンプレート
私の中にあるファイル(login.twig)をレンダリングしたいviewsファイル/views/ajax_files/login.twig
私は毎回これを行う必要がありますか?
require 'vendor/autoload.php';
$loader = new Twig_Loader_Filesystem('views/ajax_files');
$twig = new Twig_Environment($loader, array(
'cache' => 'cache',
'auto_reload' => true,
));
echo $twig->render('login.twig');
ので、私のindex.phpに、それはすでにあなたはまた、とあなたのindex.phpに直接複数のテンプレートディレクトリを定義することができ、私はDRYコード
require 'vendor/autoload.php';
$loader = new Twig_Loader_Filesystem('views');
$twig = new Twig_Environment($loader, array(
'cache' => 'cache',
'auto_reload' => true,
));
echo $twig->render('index.twig');
ありがとう –