A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.yiiframework.com/extension/yiisoft/yii2-twig/doc/guide/2.5/en/html-helper below:

Getting Started: Html helper | Twig Extension for Yii 2

Html helper

To use \yii\helpers\Html in templates you must add a Twig extension

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

and use it this way

{{ Html.a('text', 'link', {'class':'btn btn-default'}) }}

But you can't pass variables by reference for some \yii\helpers\Html methods. For example addCssClass() or addCssStyle(). Twig does not support this.

Use additional expression:

{% set favoriteButtonOptions = {
    'class': 'btn btn-default',
    'style': 'color:red'
} %}

{% css_class favoriteButtonOptions + 'btn-primary' %}


{% css_class favoriteButtonOptions - 'btn-primary' %}


{% css_style favoriteButtonOptions + 'display:none' %}


{% css_style favoriteButtonOptions - 'display' %}

или
{% css_style favoriteButtonOptions - ['display', 'color'] %}


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4