控制器:
public function content() {
return array(
'#theme' => 'test',
'#varTest' => 'toto'
);
}
模块主题挂钩:
function test_theme($existing, $type, $theme, $path) {
return [
'test' => [
'variables' => ['varTest' => 'defaultVal']
]
];
}
布局html.html.twig:
<html>
<head>
{{ varTest }}
如果我在布局中打印变量varTest为null。如果我在模板“ test”中打印变量,则varTest ='toto'
为什么布局不打印“ toto”或“ defaultVal”?