【问题标题】:How do I `use` a namespace in Yii and HAML?如何在 Yii 和 HAML 中“使用”命名空间?
【发布时间】:2015-05-24 12:22:02
【问题描述】:

我正在使用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; ?>

【问题讨论】:

标签: php yii namespaces haml yii2


【解决方案1】:

我今天修复了这个错误。
通过运行更新你的包:

composer update

或从 GitHub 下载最新版本 0.1.3

【讨论】:

    【解决方案2】:

    因为命名空间在编译时缓存无效。 请从 root nb 试试这个

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

    【讨论】:

    • Unexpected '\', expected target language expression in /.../_list.haml on line 11, column 19
    猜你喜欢
    • 1970-01-01
    • 2012-01-26
    • 1970-01-01
    • 2015-08-27
    • 1970-01-01
    • 2020-07-14
    • 1970-01-01
    • 2012-01-29
    • 2016-01-05
    相关资源
    最近更新 更多