如何使用 Blade 模板引擎在 Phalcon 框架中添加资源?

How to add assets in Phalcon framework with Blade template engine?

A 开始使用 Phalcon 框架,包括 Blade 模板。它已经有效,但不幸的是我没有找到在 master.blade.php 中包含 css 和 JS 资产的正确方法。 如果我在控制器中添加像 $this->assets->addCss("css/bootstrap.min.css"); 这样的资产,我不能将它包含在主模板文件中。

例如,我的 indexAction 如下所示:

public function indexAction(){  
    $this->assets->addCss("css/bootstrap.min.css");
    $this->assets->addJs("js/bootstrap.min.js");
    return $this->blade->make('index.index');  
}

感谢您的帮助!

好吧 - 您应该将 blade 作为实际模板引擎添加到 phalcon 视图中。

你的 class 应该 extends Engine implements EngineInterface。如果你愿意的话,最好将它添加到孵化器存储库中。

https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Mvc/View/Engine 查看其他引擎的实现,了解更多它们是如何制作的。然后你可以做 {{ assets.outputJss() }},来自 volt/twig 的示例,不确定它在 blade 中应该是什么样子,从未使用过它。

另外伏特有什么问题?它比 blade 更快,而且有很多功能。