如何在Yii和HAML中“使用”命名空间?

时间:2015-03-20 23:52:57

标签: php yii namespaces haml yii2

我正在使用MTHAML和Yii。我有以下几行。

-use yii\helpers\Url
%a{:href => Url::toRoute(['shopping/ping', 'id' => (string)$item->productId, 'category' => (string)$item->primaryCategory->categoryId])} test

但是它会出错。

语法错误,意外“使用”(T_USE)

<?php

function __MtHamlTemplate_65307eb071e28021db686cb46d491c8faae477235051858b05f212731637dd40($__variables)
{
    extract($__variables);
?><?php use yii\helpers\Url; ?>

2 个答案:

答案 0 :(得分:1)

我今天解决了这个问题 运行以下命令更新您的包:

composer update

或从GitHub下载最新版0.1.3

答案 1 :(得分:0)

由于编译html缓存时命名空间无效。 请从root nb

尝试
%a{:href => \yii\helpers\Url::toRoute(['shopping/ping', 'id' => (string)$item->productId, 'category' => (string)$item->primaryCategory->categoryId])} test
相关问题