链接内未转义的字符串 - Laravel

时间:2015-12-24 00:41:14

标签: php laravel laravel-5 laravel-blade

我在Laravel中有这行代码

{!! Illuminate\Html\HtmlFacade::link('clients', '<i class="fa fa-circle-o"></i> Pregled klijenata') !!}

当它回显href时,部分<i class="fa fa-circle-o"></i>会像文本一样回显,但我希望它是作为html的一部分编写的。你知道我做错了吗?

提前致谢:)

1 个答案:

答案 0 :(得分:1)

因为 key variant 43 "chr5:8" "9920077" 42 "chr5:9" "9920076" 39 "chr5:10" "9920073" 35 "chr5:11" "9920069" 34 "chr5:12" "9920068" 36 "chr5:13" "9920070" 37 "chr5:14" "9920071" (即:title)将转换为实体。

<i class="fa fa-circle-o"></i> Pregled klijenata

因此,您需要通过以下方式将实体转换回HTML字符:

/**
 * Generate a HTML link.
 *
 * @param string $url
 * @param string $title
 * @param array  $attributes
 * @param bool   $secure
 *
 * @return string
 */
public function link($url, $title = null, $attributes = [], $secure = null)
{
    $url = $this->url->to($url, [], $secure);

    if (is_null($title) || $title === false) {
        $title = $url;
    }

    return '<a href="'.$url.'"'.$this->attributes($attributes).'>'.$this->entities($title).'</a>';
}