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

Static Container Twig Extension Bundle Laravel Package

danilovl/static-container-twig-extension-bundle

View on GitHub
Deep Wiki
Context7

phpunit downloads latest Stable Version license

StaticContainerTwigExtensionBundle

About

Twig extension provide sharing data between templates.

Requirements

  • PHP 8.5 or higher
  • Symfony 8.0 or higher

1. Installation

Install danilovl/static-container-twig-extension-bundle package by Composer:

composer require danilovl/static-container-twig-extension-bundle

Add the StaticContainerTwigExtensionBundle to your application's bundles if does not add automatically:

<?php
// config/bundles.php

return [
    // ...
    Danilovl\StaticContainerTwigExtensionBundle\StaticContainerTwigExtensionBundle::class => ['all' => true]
];

2. Usage

Create some key with value.

{# templates/first.html.twig #}

{{ static_container_create('key', true) }}
{{ static_container_create('keyObject', object) }}
{{ static_container_create('keyArray', {'one': 1, 'two': 2}) }}
{{ static_container_create('keyWithDefaultValueNull') }}
{{ static_container_create('keyCounter', 1) }}

Control if the key exists in another template.

{# templates/second.html.twig #}

{% if static_container_has('keyCounter') == true %}
    {{ static_container_update('keyCounter', 2) }}
{% endif %}

Control if the key exists and print it.

{# templates/third.html.twig #}

{% if static_container_has('keyCounter') == true %}
   {{ static_container_get('keyCounter') }}
{% endif %}

Remove key.

{# templates/third.html.twig #}
{{ static_container_remove('sameKey') }}

License

The ApplyFilterTwigExtensionBundle is open-sourced software licensed under the MIT license.

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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle