我正在尝试将HAML与fuelPHP 1.8
一起使用第一
我通过更新require
composer.json
部分来跟踪https://github.com/fuel/parser中的一条建议
"require": {
"php": ">=5.3.3",
"composer/installers": "~1.0",
"fuel/core": "1.8.*",
"fuel/auth": "1.8.*",
"fuel/email": "1.8.*",
"fuel/oil": "1.8.*",
"fuel/orm": "1.8.*",
"fuel/parser": "1.8.*",
"fuelphp/upload": "2.0.6",
"monolog/monolog": "1.18.*",
"phpseclib/phpseclib": "2.0.0",
"michelf/php-markdown": "1.4.0",
"dwoo/dwoo" : "*",
"mustache/mustache" : "*",
"smarty/smarty" : "*",
"twig/twig" : "*",
"mthaml/mthaml": "*",
"pyrocms/lex": "*"
},
,然后
我在非常简单的HAML中写了my-view.haml
!!!
%html
%head
%meta{:charset => "utf-8"}/
%title My View
%meta{:content => "width=device-width, user-scalable=no, initial-scale=1.0", :name => "viewport"}/
%link{:href => "assets/style.min.css", :rel => "stylesheet"}/
%body
%h1 this is my view
然后在控制器中,我用
指向my-view.haml
public function action_view()
{
$view = View::forge('welcome/my-view.haml');
return Response::forge($view, 200);
}
但是
我收到以下错误:
ErrorException [ Fatal Error ]:
Method Parser\View_HamlTwig::__toString() must not throw an exception,
caught TypeError: Argument 1 passed to Twig_Environment::__construct()
must be an instance of Twig_LoaderInterface,
null given, called in /home/mickro/devel/my-prj/fuel/packages/parser/classes/view/twig.php on line 104
因此
在investigations之后,我将此twig版my-view.haml
替换为my-view.haml.twig
{% haml %}
!!!
%html
%head
%meta{:charset => "utf-8"}/
%title My View
%meta{:content => "width=device-width, user-scalable=no, initial-scale=1.0", :name => "viewport"}/
%link{:href => "assets/style.min.css", :rel => "stylesheet"}/
%body
%h1 this is my view
当我指向my-view.haml.twig
Twig似乎根本不了解HAML
Twig_Error_Syntax [ Error ]:
Unknown "haml" tag.
我迷失的地方
将HAML与fuelPHP一起使用的正确方法是什么?
答案 0 :(得分:0)
在fuelPHP forum和issue已经开启的讨论之后。
由于 haml解析器,这是一个错误。它与 twig 2 不兼容。
我暂时解决了我的问题,删除了无用的解析器并将twig移动到版本@NgModule({
imports: [ BrowserModule ],
declarations: [
App,
OptionsDirective,
MoreOptionsDirective,
],
bootstrap: [ App ]
})
,如下所示:
1.31.0