树枝的路径是什么?

时间:2016-09-16 22:17:32

标签: twig

我不是在使用交响乐,只是在树枝上。

我的结构:

root
 - assets
  - Twig (library)
 - templates
  - main_template.twig
  - child_template.twig

我的main_template.twig渲染得很好,但无法找到位于同一文件夹中的child_template.twig。

我尝试过使用相对/完整路径,但我无法加载child_template。路径应该是什么?除了将以下内容添加到子模板之外,我还需要做任何其他事情吗? (并添加块?)

{% extends "child_template.twig" %}

1 个答案:

答案 0 :(得分:0)

path相对于您在twig

的加载程序中提供的相对开始

的config.php

require_once '/path/to/lib/Twig/Autoloader.php';
Twig_Autoloader::register();

$loader = new Twig_Loader_Filesystem(__DIR__ . '/templates');
$twig = new Twig_Environment($loader);

child.twig.html

{% extends "main_template.twig" %}