Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Yii2 Twig Laravel Package

yiisoft/yii2-twig

View on GitHub
Deep Wiki
Context7

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' %}
{# equivalent Html::addCssClass($favoriteButtonOptions, 'btn-primary') #}

{% css_class favoriteButtonOptions - 'btn-primary' %}
{# equivalent Html::removeCssClass($favoriteButtonOptions, 'btn-primary') #}

{% css_style favoriteButtonOptions + 'display:none' %}
{# equivalent Html::addCssStyle($favoriteButtonOptions, 'display:none') #}

{% css_style favoriteButtonOptions - 'display' %}
{# equivalent Html::removeCssStyle($favoriteButtonOptions, 'display') #}
или
{% css_style favoriteButtonOptions - ['display', 'color'] %}
{# equivalent Html::removeCssStyle($favoriteButtonOptions, ['display', 'color']) #}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony