在 fatfree 框架中,我正在尝试编写一个函数,它可以输出缩小的 css/js 并从模板 htm 中调用它。但似乎一旦我尝试使用 htm 调用该函数,整个页面就会呈现为文本,包括 doctype 和所有标签。
我的控制器只有:
public function index($f3, $params) {
echo \Template::instance()->render($this->BM->themeAbsPath('user_group.htm'));
}
在 .htm 模板中,我有:
<style>
{{ @BM->minify('css','css/',array(
'bootstrap-theme.min.css',
'main.css',
'vendor/smartmenus-0.9.5/addons/bootstrap/jquery.smartmenus.bootstrap.css',
'vendor/datatables/css/jquery.dataTables.css',
'vendor/datatables/css/jquery.dataTables_themeroller.css'
)) }}
</style>
最后是函数:
public function minify($type='css',$folderpath='css/',$files=array()){
$filepaths = implode(",",$files);
$this->f3->set('UI',$this->themeRelFolder().'/'.$folderpath);
$this->f3->set('minified_'.$type,\Web::instance()->minify($filepaths));
return $this->f3->get('minified_'.$type);
}
我没有收到任何 500 错误或类似的错误,那我做错了什么?