wucdbm/twig-defer-extension

Defer rendering of TWIG template pieces

v3.1.3 2022-11-28 04:27 UTC

This package is auto-updated.

Last update: 2024-11-28 08:40:37 UTC


README

Using this small library you can "cache" the output of twig code and print it later.

Use the {% defer %} tag to cache your output. Both {% defer NAME EXPRESSION %} and {% defer NAME %} EXPRESSION {% enddefer %} are possible.

    {% defer 'someKey' 'defaultValueExpression' %}
    {% defer someKeyVariable 'someDefaultValueExpression' %}
    {% defer 'someKey' %}
        someBlock {{ with Variables }}
    {% enddefer %}
    
    {% if 'someKey' is deferred %}
    {% if someVariableValue is deferred %}
    
    {{ someKey|deferred('defaultValue') }}