Twig模板变量不显示?

时间:2018-02-13 02:24:28

标签: twig

我访问twig实例,并像这样呈现模板:

return $this->template->render('login.html', array(
    'name' => 'John Smith',
    'age' => 32,
    'location' => 'Egypt'
));

这是事物的模板方面

Hello, my name is {{ name }}, my age is {{ age }}, and my location is {{ location }}.

目前打印出来

Hello, my name is , my age is , and my location is .

应打印

Hello, my name is John Smith, my age is 32, and my location is Egypt.

1 个答案:

答案 0 :(得分:-1)

检查Symfony docs Rendering Templates

return $this->render('login.html', array(
    'name' => 'John Smith',
    'age' => 32,
    'location' => 'Egypt'
));