Skip to content

Bundle not loading Twig extensions #5

@EvanK

Description

@EvanK

I have filters being loaded from both the official Text twig extension and a custom extension I've written, both configured via my config.yml:

services:
    text.twig.extension:
         class: Twig_Extensions_Extension_Text
         tags: [{ name: twig.extension }]
    custom_filter.twig.extension:
        class: Project\Bundle\ExampleBundle\Extension\CustomFilterExtension
        tags: [{ name: twig.extension }]

They are being used in normal twig templates without issue:

{% set myvar = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." %}
{{ myvar|truncate(10) }}
{# prints "Lorem ipsu..." #}

However, trying to use them with the TwigstringBundle throws a Twig_Error_Syntax exception with a message of The filter "truncate" does not exist:

$this->get('twigstring')->render('{{ myvar|truncate(10) }}', array('myvar' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions