yiisoft/yii2-twig

HtmlHelperExtension not work

falkolab opened this issue · 1 comments

What steps will reproduce the problem?

Add to extensions array in config

'extensions' => [
    \yii\twig\html\HtmlHelperExtension::class,
],

What's expected?

Not empty output for:
{{ html.a('any', 'url, { 'class': '123' }) }}

What do you get instead?

Empty output

Additional info

https://twig.symfony.com/doc/2.x/advanced.html#id1

Worked example:

<?php

namespace app\twig\html;
use yii\twig\html\CssClass_TokenParser;
use yii\twig\html\CssStyle_TokenParser;
use yii\helpers\Html;

class HtmlHelperExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{
    public function getTokenParsers()
    {
        return [
            new CssClass_TokenParser(),
            new CssStyle_TokenParser()
        ];
    }

    public function getGlobals()
    {
        return [
            'html' => new Html(),
        ];
    }
}
Q A
Yii version 2.0.13
Yii Twig version 2.2.0
Twig version 2.4.6
PHP version 7.1.9
Operating system Ubuntu xenial

have some problem, version 2.2.1

  • when do {{ html.a('Rbac', '/rbac', {'class':'item'}) }} then in html &lt ;a class="item"&gt ;Rbac&lt ;/a&gt ;
  • when do when do {{ Html.a('Rbac', '/rbac', {'class':'item'}) }} in html empty place