【发布时间】:2016-07-22 13:53:38
【问题描述】:
不确定 Smarty 是否正在加载,但它直接在页面上显示 {$title} 和 {$username} 而不是使用设置为变量的内容。
我添加到composer.json中
“聪明/聪明”:“*”
我运行php composer.phar update 和install:
我正在根据解析器在 config.php 文件中加载
'packages' => array(
'orm',
'auth',
'parser',
),
在我的控制器dashboard.php中
public function action_index()
{
$data = [
'bodyclass' => "dashboard",
'title' => "Dashboard",
'username' => "James"
];
$view = Response::forge(View::forge('dashboard/index.tpl', $data));
$this->template->subnav = array('dashboard'=> 'active' );
$this->template->content = $view;
}
在我的 index.tpl 文件中有
{$title} {$username}
这只是为了测试,但似乎不起作用。
【问题讨论】:
-
抱歉回复晚了,刚看到。除了您不应该将视图包装到响应中这一事实之外,我没有立即看到任何错误。您确定双括号用作分隔符,而不是单括号(这是默认设置,请参阅解析器包中的 parser.php 配置文件)。